WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

Commit 60066172 authored by John Zhang's avatar John Zhang
Browse files

functionality test for performance targets

parent 1940de0e
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rlib import rmu_fast as rmu
from util import fncptr_from_rpy_func, fncptr_from_py_script, call_and_check
import ctypes
def test_fibonacci():
from perftarget.fibonacci import fib
fnc, (db, bdlgen) = fncptr_from_rpy_func(fib, [rffi.ULONGLONG], rffi.ULONGLONG)
bdlgen.mu.current_thread_as_mu_thread(rmu.null(rmu.MuCPtr))
def check(f):
assert f == 6765
call_and_check(fnc, (rffi.cast(rffi.ULONGLONG, 20), ), check)
def test_fibonacci_iterative():
def fib_iter(n):
if n <= 1:
return n
k = 2
fib_k_2 = 0
fib_k_1 = 1
fib_k = 0
while k <= n:
fib_k = fib_k_2 + fib_k_1
fib_k_2 = fib_k_1
fib_k_1 = fib_k
k += 1
return fib_k
fnc, (db, bdlgen) = fncptr_from_rpy_func(fib_iter, [rffi.ULONGLONG], rffi.ULONGLONG)
bdlgen.mu.current_thread_as_mu_thread(rmu.null(rmu.MuCPtr))
def check(f):
assert f == 6765
call_and_check(fnc, (rffi.cast(rffi.ULONGLONG, 20),), check)
\ No newline at end of file
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rlib import rmu_fast as rmu
from util import fncptr_from_rpy_func, fncptr_from_py_script, proc_call, call_and_check
from util import fncptr_from_rpy_func, fncptr_from_py_script, call_and_check
import ctypes
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment