Skip to content

Commit b1590e5

Browse files
committed
ipynb for timeit
1 parent e0f29b6 commit b1590e5

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

timeit_test.ipynb

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"metadata": {
3+
"name": ""
4+
},
5+
"nbformat": 3,
6+
"nbformat_minor": 0,
7+
"worksheets": [
8+
{
9+
"cells": [
10+
{
11+
"cell_type": "code",
12+
"collapsed": false,
13+
"input": [
14+
"import timeit\n",
15+
"\n",
16+
"def test_format():\n",
17+
" return ['{}'.format(i) for i in range(1000000)]\n",
18+
"\n",
19+
"def test_binaryop():\n",
20+
" return ['%s' %i for i in range(1000000)]\n",
21+
"\n",
22+
"%timeit test_format()\n",
23+
"%timeit test_binaryop()\n",
24+
"\n",
25+
"#print('{}: {}\\n{}: {}'.format('format()', format_res, '%s', binaryop_res))\n",
26+
"\n",
27+
"################################\n",
28+
"# On my machine\n",
29+
"################################\n",
30+
"#\n",
31+
"# Python 3.4.0\n",
32+
"# MacOS X 10.9.2\n",
33+
"# 2.5 GHz Intel Core i5\n",
34+
"# 4 GB 1600 Mhz DDR3\n",
35+
"#\n"
36+
],
37+
"language": "python",
38+
"metadata": {},
39+
"outputs": [
40+
{
41+
"output_type": "stream",
42+
"stream": "stdout",
43+
"text": [
44+
"1 loops, best of 3: 400 ms per loop\n",
45+
"1 loops, best of 3: 241 ms per loop"
46+
]
47+
},
48+
{
49+
"output_type": "stream",
50+
"stream": "stdout",
51+
"text": [
52+
"\n"
53+
]
54+
}
55+
],
56+
"prompt_number": 3
57+
},
58+
{
59+
"cell_type": "code",
60+
"collapsed": false,
61+
"input": [],
62+
"language": "python",
63+
"metadata": {},
64+
"outputs": []
65+
}
66+
],
67+
"metadata": {}
68+
}
69+
]
70+
}

0 commit comments

Comments
 (0)