Exemplo n.º 1
0
one_iter = 1000000 * n_iterations
used_time = 0

py_iter = one_iter / 100

myrange = xrange(py_iter)
border = "+%s+" % ("-" * (17 + 3 * (16 +3) + 2))
print border
tmp = ("runs/us", "ns/run") * 3
print "|%-14s| %17s || %17s || %17s |" % (" ","Array", "Py Loop", "Old Impl") 
print "|%-14s| %7s | %7s || %7s | %7s || %7s | %7s |" %( ("Name", ) + tmp)
print border

method = 'landau'
#method = 'get'
for i in rng.types_setup():
    r = rng.rng(getattr(rng, i))
    try:
	ra = getattr(rnga, 'rng_' + i)()
    except AttributeError:
	continue

    call = getattr(r, method)
    t1 = time.clock()
    a = call(one_iter)
    t2 = time.clock()
    used_time = (t2 - t1)
    del a
    t = (r.name(),
         (one_iter * 1.0) / used_time * 1e-6,
         used_time / (one_iter * 1.0) * 1e9)
Exemplo n.º 2
0
import types
import unittest
import math
import copy
import Numeric
import MLab
import pygsl.testing.rng as rngmodule
import sys
sys.stdout = sys.stderr
rng_types = rngmodule.types_setup()


class _rng_type:
    _type = None


for i in rng_types:
    tmp = "class %s(_rng_type): _type = rngmodule.%s" % ((i, ) * 2)
    exec(tmp)


class _rng_basics(unittest.TestCase):
    """
    here are things tested like allocation, destruction, initialisation
    """
    def test_alloc(self):
        """
        allocate the default rng
        """
        rng = rngmodule.rng(self._type)
        self.failIf(rng.name() == "", "name of rng was \"\"")
Exemplo n.º 3
0
import types
import unittest
import math
import copy
import Numeric
import MLab
import pygsl.testing.rng as rngmodule
import sys
sys.stdout = sys.stderr
rng_types = rngmodule.types_setup()


class _rng_type:
    _type = None

for i in rng_types:
    tmp = "class %s(_rng_type): _type = rngmodule.%s" % ((i,) * 2)
    exec(tmp)


class _rng_basics(unittest.TestCase):
    """
    here are things tested like allocation, destruction, initialisation
    """
    def test_alloc(self):
        """
        allocate the default rng
        """
        rng=rngmodule.rng(self._type)
        self.failIf(rng.name()=="","name of rng was \"\"")
        self.failIf(rng.name() is None,"name of rng was None")
Exemplo n.º 4
0
one_iter = 1000000 * n_iterations
used_time = 0

py_iter = one_iter / 100

myrange = xrange(py_iter)
border = "+%s+" % ("-" * (17 + 3 * (16 + 3) + 2))
print border
tmp = ("runs/us", "ns/run") * 3
print "|%-14s| %17s || %17s || %17s |" % (" ", "Array", "Py Loop", "Old Impl")
print "|%-14s| %7s | %7s || %7s | %7s || %7s | %7s |" % (("Name", ) + tmp)
print border

method = 'landau'
#method = 'get'
for i in rng.types_setup():
    r = rng.rng(getattr(rng, i))
    try:
        ra = getattr(rnga, 'rng_' + i)()
    except AttributeError:
        continue

    call = getattr(r, method)
    t1 = time.clock()
    a = call(one_iter)
    t2 = time.clock()
    used_time = (t2 - t1)
    del a
    t = (r.name(), (one_iter * 1.0) / used_time * 1e-6,
         used_time / (one_iter * 1.0) * 1e9)