performance measurements

Each table row shows performance measurements for this Lua program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
2,000Failed  414   

Read the ↓ make, command line, and program output logs to see how this program was run.

Read pidigits benchmark to see what this program should do.


Lua 5.3.0 Copyright (C) 1994-2015, PUC-Rio

 pidigits Lua #3 program source code

-- The Computer Language Benchmarks Game
-- contributed by Mike Pall
-- requires LGMP "A GMP package for Lua 5.1"

local g = {}; require"c-gmp"(g, {})
local add, mul, submul = g.mpz_add, g.mpz_mul_si, g.mpz_submul_ui
local mul2x, div, cmp = g.mpz_mul_2exp, g.mpz_fdiv_qr, g.mpz_cmp
local init, get, write = g.mpz_init_set_d, g.mpz_get_d, io.write

local N = tonumber(arg and arg[1]) or 100
local i, n, a, d, t, u = 0, init(1), init(0), init(1), init(0), init(0)
for k=1,1000000 do
  mul2x(n, 1, t) mul(n, k, n) add(a, t, a) mul(a, k+k+1, a) mul(d, k+k+1, d)
  if cmp(a, n) >= 0 then
    mul2x(n, 1, t) add(t, n, t) add(t, a, t) div(t, d, t, u) add(u, n, u)
    if cmp(d, u) > 0 then
      local y = get(t)
      write(y); i = i + 1; if i % 10 == 0 then write("\t:", i, "\n") end
      if i >= N then break end
      submul(a, d, y) mul(a, 10, a) mul(n, 10, n)
if i % 10 ~= 0 then write(string.rep(" ", 10 - N % 10), "\t:", N, "\n") end

 make, command-line, and program output logs

Mon, 12 Jan 2015 21:41:03 GMT

/usr/local/src/lua-5.3.0/bin/lua  pidigits.lua-3.lua 2000



/usr/local/src/lua-5.3.0/bin/lua: pidigits.lua-3.lua:6: module 'c-gmp' not found:
	no field package.preload['c-gmp']
	no file '/usr/local/share/lua/5.3/c-gmp.lua'
	no file '/usr/local/share/lua/5.3/c-gmp/init.lua'
	no file '/usr/local/lib/lua/5.3/c-gmp.lua'
	no file '/usr/local/lib/lua/5.3/c-gmp/init.lua'
	no file './c-gmp.lua'
	no file './c-gmp/init.lua'
	no file '/usr/local/lib/lua/5.3/'
	no file '/usr/local/lib/lua/5.3/'
	no file './'
stack traceback:
	[C]: in function 'require'
	pidigits.lua-3.lua:6: in main chunk
	[C]: in ?

Revised BSD license

  Home   Conclusions   License   Play