-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark_buble.py
More file actions
35 lines (29 loc) · 842 Bytes
/
benchmark_buble.py
File metadata and controls
35 lines (29 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import subprocess
from datetime import datetime
import os
def call_func(cmd,msg):
print ""
print "=" * 60
print"test " + msg + " Start:"
t1 = datetime.now()
for x in xrange(1,100):
subprocess.call(cmd, shell=True)
t2 = datetime.now()
print ""
print msg + "run 100 times " + "total time is :" ,t2-t1
print "test " + msg + " end"
print "=" * 60
def test_func():
print "_" * 60
print "bubble sort benchmark test start"
print "_" * 60
os.chdir(os.getcwd())
call_func("ruby bubble_sort.rb", "ruby bubble sort")
call_func("python bubble_sort.py" , "python bubble sort")
call_func("perl buble_sort.pl", "perl bubble sort")
call_func("./a.out", "go bubble sort")
call_func("./bu_c.out", "C bubble sort")
print "_" * 60
print "bubble sort benchmark test End"
print "_" * 60
test_func()