Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit dd489df

Browse files
committed
fix profile_vm.py script
1 parent 5c0ab60 commit dd489df

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ethereum/tests/profile_vm.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
import ethereum.testutils as testutils
44
import cProfile
55
import pstats
6-
import StringIO
76
import time
87
from rlp.utils import encode_hex
9-
from ethereum.utils import sha3
8+
from ethereum.utils import sha3, to_string
109
from ethereum.slogging import get_logger
1110
logger = get_logger()
1211

1312

13+
if sys.version_info.major == 2:
14+
from io import BytesIO as StringIO
15+
else:
16+
from io import StringIO
17+
18+
1419
def do_test_vm(filename, testname=None, testdata=None, limit=99999999, profiler=None):
1520
logger.debug('running test:%r in %r' % (testname, filename))
1621
testutils.run_vm_test(testutils.fixture_to_bytes(testdata), testutils.VERIFY, profiler=profiler)
@@ -31,15 +36,15 @@ def run(profiler=None):
3136
if i == num:
3237
break
3338
do_test_vm(filename, testname, testdata, profiler=profiler)
34-
seen += str(testname)
39+
seen += to_string(testname)
3540
i += 1
3641
print('ran %d tests' % i)
3742
print('test key', encode_hex(sha3(seen)))
3843

3944
if len(sys.argv) == 1:
4045
pr = cProfile.Profile()
4146
run(pr)
42-
s = StringIO.StringIO()
47+
s = StringIO()
4348
sortby = 'tottime'
4449
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
4550
ps.print_stats(50)

0 commit comments

Comments
 (0)