Exemplo n.º 1
0
def test_sumr_compile(queue, func, n, setup_func):
    array, module = setup_func("R")
    r_loopsum = """
#-- purer_sum-begin
function(x)
{
  total = 0;
  for (elt in x) {
    total <- total + elt
  } 
}
#-- purer_sum-end
"""
    
    rdo_loopsum = """
f <- %s
for (i in 1:%i) {
  res <- f(x)
}
"""
    compiler = ro.packages.importr("compiler")
    rcode = rdo_loopsum %("compiler::cmpfun("+r_loopsum+")", n)
    time_beg = time.time()
    #print(rcode)
    module.r(rcode)
    time_end = time.time()
    queue.put(time_end - time_beg)
Exemplo n.º 2
0
def test_sumr(queue, func, n, setup_func):
    array, module = setup_func("R")
    r_loopsum = """
#-- purer_sum-begin
function(x)
{
  total = 0;
  for (elt in x) {
    total <- total + elt
  } 
}
#-- purer_sum-end
"""

    rdo_loopsum = """
f <- %s
for (i in 1:%i) {
  res <- f(x)
}
"""
    rcode = rdo_loopsum %(r_loopsum, n)
    time_beg = time.time()
    #print(rcode)
    module.r(rcode)
    time_end = time.time()
    queue.put(time_end - time_beg)
Exemplo n.º 3
0
def test_sumr_compile(queue, func, n, setup_func):
    array, module = setup_func("R")
    r_loopsum = """
#-- purer_sum-begin
function(x)
{
  total = 0;
  for (elt in x) {
    total <- total + elt
  } 
}
#-- purer_sum-end
"""

    rdo_loopsum = """
f <- %s
for (i in 1:%i) {
  res <- f(x)
}
"""
    compiler = ro.packages.importr("compiler")
    rcode = rdo_loopsum % ("compiler::compile(" + r_loopsum + ")", n)
    time_beg = time.time()
    #print(rcode)
    module.r(rcode)
    time_end = time.time()
    queue.put(time_end - time_beg)
Exemplo n.º 4
0
def test_sumr(queue, func, n, setup_func):
    array, module = setup_func("R")
    r_loopsum = """
#-- purer_sum-begin
function(x)
{
  total = 0;
  for (elt in x) {
    total <- total + elt
  } 
}
#-- purer_sum-end
"""

    rdo_loopsum = """
f <- %s
for (i in 1:%i) {
  res <- f(x)
}
"""
    rcode = rdo_loopsum % (r_loopsum, n)
    time_beg = time.time()
    #print(rcode)
    module.r(rcode)
    time_end = time.time()
    queue.put(time_end - time_beg)
Exemplo n.º 5
0
def test_sumr_builtin(queue, func, n, setup_func):
    array, module = setup_func("R")
    r_sum = """
sum
"""
    
    rdo_loopsum = """
f <- %s
for (i in 1:%i) {
  res <- f(x)
}
"""
    rcode = rdo_loopsum %(r_sum, n)
    time_beg = time.time()
    #print(rcode)
    module.r(rcode)
    time_end = time.time()
    queue.put(time_end - time_beg)
Exemplo n.º 6
0
def test_sumr_builtin(queue, func, n, setup_func):
    array, module = setup_func("R")
    r_sum = """
sum
"""

    rdo_loopsum = """
f <- %s
for (i in 1:%i) {
  res <- f(x)
}
"""
    rcode = rdo_loopsum % (r_sum, n)
    time_beg = time.time()
    #print(rcode)
    module.r(rcode)
    time_end = time.time()
    queue.put(time_end - time_beg)