Git Product home page Git Product logo

Comments (9)

nschloe avatar nschloe commented on May 25, 2024

Ah, right. Could you attach an example profile so I can play around with it?

from tuna.

eric-wieser avatar eric-wieser commented on May 25, 2024

Sure:

$ cat nope.py
import os
import sys
raise ValueError("Not a chance")
$ python3.7 -X importtime nope.py 2> import.log
$ cat import.log
import time: self [us] | cumulative | imported package
import time:       124 |        124 | zipimport
import time:       708 |        708 | _frozen_importlib_external
import time:       113 |        113 |     _codecs
import time:      1018 |       1130 |   codecs
import time:      1080 |       1080 |   encodings.aliases
import time:      2682 |       4891 | encodings
import time:       619 |        619 | encodings.utf_8
import time:        96 |         96 | _signal
import time:       610 |        610 | encodings.latin_1
import time:        65 |         65 |     _abc
import time:       656 |        720 |   abc
import time:       760 |       1479 | io
import time:       105 |        105 |   _locale
import time:       805 |        909 | _bootlocale
import time:       494 |        494 | encodings.cp1252
import time:       105 |        105 |       _stat
import time:       707 |        811 |     stat
import time:       444 |        444 |       genericpath
import time:      1382 |       1826 |     ntpath
import time:      1543 |       1543 |     _collections_abc
import time:      1304 |       5482 |   os
import time:       582 |        582 |   _sitebuiltins
import time:       773 |        773 |   sitecustomize
import time:       293 |        293 |   usercustomize
import time:      1787 |       8914 | site
Traceback (most recent call last):
  File "nope.py", line 3, in <module>
    raise ValueError("Not a chance")
ValueError: Not a chance

from tuna.

eric-wieser avatar eric-wieser commented on May 25, 2024

I think you should be filtering for lines that start import time: and ignoring all the rest

from tuna.

eric-wieser avatar eric-wieser commented on May 25, 2024

Possibly not fixed - tuna no longer crashes any more, but it will still produce an incomplete import time report if the py -Ximporttime 2> log raised an exception. Perhaps tuna should handle invoking python so that it can detect this via the return code?

from tuna.

nschloe avatar nschloe commented on May 25, 2024

Hm, perhaps including this wasn't a good idea. Now we have a situation where tuna silently produces an incomplete ("wrong") result where before it at least crashed. Perhaps we can make sure it exits more gracefully if the file cannot be parsed properly.

from tuna.

eric-wieser avatar eric-wieser commented on May 25, 2024

#14 was still correct, because it means it no longer fails if the module imported writes to sys.stderr. Arguably detecting whether the import crashed isn't tunas problem anyway - the user should be checking that when they invoke python. Something like

python37 -X importtime -c 'import mymodule' 2> import.log \
    && tuna import.log \
    || {echo "failed"; exit 1; }

(I'm on windows so can't actually test that)

from tuna.

nschloe avatar nschloe commented on May 25, 2024

#14 was still correct, because it means it no longer fails if the module imported writes to sys.stderr.

Isn't this already an indication of something going on, i.e., something that requires user attention?

Btw

python36 -X importtime

This works??

from tuna.

eric-wieser avatar eric-wieser commented on May 25, 2024

This works??

That was supposed to be 37

Isn't this already an indication of something going, i.e., something that requires user attention?

Could just be a warning printed to stderr, not necessarily a traceback. Perhaps tuna should just print out the lines it doesn't recognize? Or maybe even include them at the bottom of the web page.

from tuna.

nschloe avatar nschloe commented on May 25, 2024

Perhaps tuna should just print out the lines it doesn't recognize?

I like that.

from tuna.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.