FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python_reference/timeit_test.py at master · wavelets/python_reference · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
wavelets
/
python_reference
Public
forked from
rasbt/python_reference
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python_reference
/
timeit_test.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (19 loc) · 612 Bytes
Breadcrumbs
python_reference
/
timeit_test.py
Copy path
File metadata and controls
24 lines (19 loc) · 612 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Sebastian Raschka, 03/2014
# comparing string formating: %s and .format()
import
timeit
format_res
=
timeit
.
timeit
(
"['{}'.format(i) for i in range(10000)]"
,
number
=
1000
)
binaryop_res
=
timeit
.
timeit
(
"['%s' %i for i in range(10000)]"
,
number
=
1000
)
print
(
'{}: {}
\n
{}: {}'
.
format
(
'format()'
,
format_res
,
'%s'
,
binaryop_res
))
################################
# On my machine
################################
#
# Python 3.4.0
# MacOS X 10.9.2
# 2.5 GHz Intel Core i5
# 4 GB 1600 Mhz DDR3
#
################################
# format(): 2.815331667999999
# %s: 1.630353775999538
################################
Back
|
FazBrowse Home
|
New Git URL