python
Python Measure the execution time of small bits of Python code with the timeit module
>>> import timeit
>>> timeit.timeit('"-".join(str(n) for n in range(100))',
number=10000)
0.3412662749997253
>>> timeit.timeit('"-".join([str(n) for n in range(100)])',
number=10000)
0.2996307989997149
>>> timeit.timeit('"-".join(map(str, range(100)))',
number=10000)
0.24581470699922647
Was this helpful?
Similar Posts
- Add delay in code execution python
- Filter by current time - n hours SQLAlchemy
- [Python] Two ways to import a module
- [Python] Get nodeid, module, function name using Pytest request built-in fixture
- [Python] Using inspect.stack() to get module name, path, function name
- How to generate a random number in python using random module
- first python code