├── LICENSE ├── README.md ├── importtime_demo.png └── index.html /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Kevin Michel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # python-importtime-graph 2 | Display a treemap of the timings reported by `python -X importtime` 3 | 4 | ![A treemap sample](/importtime_demo.png?raw=true) 5 | 6 | Try it: https://kmichel.github.io/python-importtime-graph/ 7 | 8 | ## Usage 9 | 10 | Run your python program with the `-X importtime` option, available 11 | since [Python 3.7][doc]. 12 | 13 | The program will output timing statistics on stderr : 14 | 15 | import time: self [us] | cumulative | imported package 16 | import time: 137 | 137 | zipimport 17 | import time: 674 | 674 | _frozen_importlib_external 18 | import time: 84 | 84 | _codecs 19 | import time: 705 | 789 | codecs 20 | import time: 757 | 757 | encodings.aliases 21 | import time: 1115 | 2659 | encodings 22 | import time: 461 | 461 | encodings.utf_8 23 | import time: 190 | 190 | _signal 24 | import time: 488 | 488 | encodings.latin_1 25 | import time: 72 | 72 | _abc 26 | import time: 456 | 528 | abc 27 | import time: 574 | 1101 | io 28 | import time: 102 | 102 | _locale 29 | import time: 319 | 420 | _bootlocale 30 | 31 | Copy these stats and then paste them using the button in the web page above. 32 | 33 | You can also save the stats to a file and open the file in the web page. 34 | 35 | python -X importtime [YOUR_PROGRAM] 2> importtime.txt 36 | 37 | Once rendered, you can download the output in SVG or PNG format. 38 | 39 | [doc]: https://docs.python.org/3/using/cmdline.html#id5 40 | -------------------------------------------------------------------------------- /importtime_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kmichel/python-importtime-graph/c66fa0cb2f03864bdbb92c747dc13d6356eacba5/importtime_demo.png -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | python -X importtime 5 | 6 | 7 | 8 | 111 | 112 | 113 |
114 |

Python -X importtime

115 |
116 | 117 | Download SVG 118 | Download PNG 119 | 122 |
123 | 124 | 125 | 126 | 127 | 128 | 298 | 299 | 300 | --------------------------------------------------------------------------------