Author: Antonio Cuni <[email protected]>
Branch:
Changeset: r44806:2eb925af02f3
Date: 2011-06-07 16:47 +0200
http://bitbucket.org/pypy/pypy/changeset/2eb925af02f3/
Log: move this test into the appropriate file
diff --git a/pypy/module/pypyjit/test_pypy_c/test__ffi.py
b/pypy/module/pypyjit/test_pypy_c/test__ffi.py
--- a/pypy/module/pypyjit/test_pypy_c/test__ffi.py
+++ b/pypy/module/pypyjit/test_pypy_c/test__ffi.py
@@ -72,6 +72,36 @@
# we only force the virtualref, not its content
assert opnames.count('new_with_vtable') == 1
+ def test__ffi_call_releases_gil(self):
+ from pypy.rlib.test.test_libffi import get_libc_name
+ def main(libc_name, n):
+ import time
+ from threading import Thread
+ from _ffi import CDLL, types
+ #
+ libc = CDLL(libc_name)
+ sleep = libc.getfunc('sleep', [types.uint], types.uint)
+ delays = [0]*n + [1]
+ #
+ def loop_of_sleeps(i, delays):
+ for delay in delays:
+ sleep(delay) # ID: sleep
+ #
+ threads = [Thread(target=loop_of_sleeps, args=[i, delays]) for i
in range(5)]
+ start = time.time()
+ for i, thread in enumerate(threads):
+ thread.start()
+ for thread in threads:
+ thread.join()
+ end = time.time()
+ return end - start
+ #
+ log = self.run(main, [get_libc_name(), 200], threshold=150)
+ assert 1 <= log.result <= 1.5 # at most 0.5 seconds of overhead
+ loops = log.loops_by_id('sleep')
+ assert len(loops) == 1 # make sure that we actually JITted the loop
+
+
def test_ctypes_call(self):
from pypy.rlib.test.test_libffi import get_libm_name
def main(libm_name):
diff --git a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
--- a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
@@ -191,36 +191,6 @@
for opname in log.opnames(loop.allops(opcode="IMPORT_NAME")):
assert 'call' not in opname # no call-like opcode
-
- def test__ffi_call_releases_gil(self):
- from pypy.rlib.test.test_libffi import get_libc_name
- def main(libc_name, n):
- import time
- from threading import Thread
- from _ffi import CDLL, types
- #
- libc = CDLL(libc_name)
- sleep = libc.getfunc('sleep', [types.uint], types.uint)
- delays = [0]*n + [1]
- #
- def loop_of_sleeps(i, delays):
- for delay in delays:
- sleep(delay) # ID: sleep
- #
- threads = [Thread(target=loop_of_sleeps, args=[i, delays]) for i
in range(5)]
- start = time.time()
- for i, thread in enumerate(threads):
- thread.start()
- for thread in threads:
- thread.join()
- end = time.time()
- return end - start
- #
- log = self.run(main, [get_libc_name(), 200], threshold=150)
- assert 1 <= log.result <= 1.5 # at most 0.5 seconds of overhead
- loops = log.loops_by_id('sleep')
- assert len(loops) == 1 # make sure that we actually JITted the loop
-
def test_unpack_iterable_non_list_tuple(self):
def main(n):
import array
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit