示例#1
0
def run_test2(n, r, i):
    """ Run thread safety test to make sure the cache statistics
    are correct."""
    fib.cache_clear()
    setinterval(i)
    threads = [Thread(target=run_fib_with_stats, args=(r, )) for _ in range(n)]
    run_threads(threads)

    hits, misses, maxsize, currsize = fib.cache_info()
    if misses != CACHE_SIZE:
        raise ValueError("Expected %d misses, Got %d" % (CACHE_SIZE, misses))
    if maxsize != CACHE_SIZE:
        raise ValueError("Expected %d maxsize, Got %d" % (CACHE_SIZE, maxsize))
    if currsize != CACHE_SIZE:
        raise ValueError("Expected %d currsize, Got %d" %
                         (CACHE_SIZE, currsize))
示例#2
0
def run_test2(n, r, i):
    """ Run thread safety test to make sure the cache statistics
    are correct."""
    fib.cache_clear()
    setinterval(i)
    threads = [Thread(target=run_fib_with_stats, args=(r, )) for _ in range(n)]
    run_threads(threads)

    hits, misses, maxsize, currsize = fib.cache_info()
    if misses != CACHE_SIZE:
        raise ValueError("Expected %d misses, Got %d" %
                         (CACHE_SIZE, misses))
    if maxsize != CACHE_SIZE:
        raise ValueError("Expected %d maxsize, Got %d" %
                         (CACHE_SIZE, maxsize))
    if currsize != CACHE_SIZE:
        raise ValueError("Expected %d currsize, Got %d" %
                         (CACHE_SIZE, currsize))
示例#3
0
 def setUp(self):
     setinterval(1e-6)
     self.numthreads = 4
     self.repeat = 1000
示例#4
0
def run_test(n, r, i):
    """ Run thread safety test with n threads r times using interval i. """
    setinterval(i)
    threads = [Thread(target=run_fib_with_clear, args=(r, )) for _ in range(n)]
    run_threads(threads)
示例#5
0
文件: test_thread.py 项目: Vasyka/hat
 def setUp(self):
     setinterval(1e-6)
     self.numthreads = 4
     self.repeat = 1000
示例#6
0
def run_test(n, r, i):
    """ Run thread safety test with n threads r times using interval i. """
    setinterval(i)
    threads = [Thread(target=run_fib_with_clear, args=(r, )) for _ in range(n)]
    run_threads(threads)