News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
murgaLua CGI %ENV
Author Message
Juergen
Member
***


Posts: 81
Group: Registered
Joined: May 2007
Status: Offline
Reputation: 0
Post: #1
RE: murgaLua CGI %ENV

JohnMurga Wrote:
Not really a fair comparison as once you incorporate the relevant bindings to stock lua the startup time will increase too... Although if you are going to use murgaLua for CGI you probably should unpack it.

Would be interesting to measure it. But I guess it will still be a lot faster even when the sql bindings are loaded dynamically.

JohnMurga Wrote:
FYI, the XML bindings and a few other bits and pieces are also not available elsewhere ;-)

I know, but most functionality is available in another form on luaforge.

JohnMurga Wrote:
BTW, I'd like to see a test to prove your 30% file overhead claim from an earlier post.


Code:
unction iotest(filename, isize)
  local obytes=0
  local video=assert(io.open(filename,"r"),"Cant open file: "..filename)
  local devnull=assert(io.open("/dev/null","w"),"Cant open /dev/null")
  local size=video:seek("end")
  video:seek("set")

  local vs,pos,iterations
  iterations=size/isize

  while(iterations>=0) do
    vs=video:read(isize)
    devnull:write(vs)
    obytes=obytes+#vs
    iterations=iterations-1
  end
  video:close()
  return obytes
end
if type(arg[1])~="string" then print("You must prowide a filename as the first argument!") os.exit(1) else fn=arg[1]  end
if not arg[2] or not tonumber(arg[2]) then print("You must prvide a chunksize as the second argument!") os.exit(1) else cs=tonumber(arg[2]) end
print(iotest(fn,cs).." bytes written to /dev/null")


You should save that as io_speed.lua

and this:

Code:
#!/bin/bash
export TIMEFORMAT="%5R %5U %5S"
blocksize=${2:-10000}
filename=${1:?"The first parameter should be a large file! (additionally blocksize and runs could also be specified)"}
if ! [ -f $filename ] ; then echo "the file should exist!" ; exit -1 ; fi
runs=${3:-20}
offset=3 #to make sure the caches are warm
stock_lua=lua5.1
murgaLua=murgaLua
luascript=io_speed.lua
if ! [ -f $luascript ] ; then "where is the lua script?" ; exit -1 ; fi

function io_test () {
   local interp="$1"
   local pref="$2"
   shift 2
   local param="$@"
   for ((i=1;i<=runs;i++)) do
     echo run: $i with $interp $param
     tstring=$({ time $interp $param > /dev/null 2>&1 ; } 2>&1)
     set -- $(IFS=' ' ; echo $tstring)
     echo real: $1 user: $2 system: $3
     eval $pref\_real[$i]=$1
     eval $pref\_user[$i]=$2
     eval $pref\_system[$i]=$3
   done
}

function calculate_result() {
   local pref=$1
   result_real=0; result_system=0; result_user=0
   local real=$pref"_real" user=$pref"_user" system=$pref"_system"
   for ((i=$offset;i<=runs;i++)) do
     result_real=$(eval dc -e \"5 k $result_real \${$real[$i]} + p\")
     result_user=$(eval dc -e \"5 k $result_user \${$user[$i]} + p\")
     result_system=$(eval dc -e \"5 k $result_system \${$system[$i]} + p\")
   done
   result_real=$(eval dc -e \"5 k $result_real $runs $offset -  / p\")
   result_user=$(eval dc -e \"5 k $result_user $runs $offset -  / p\")
   result_system=$(eval dc -e \"5 k $result_system $runs $offset - / p\")
   eval $pref\_real[0]=$result_real
   eval $pref\_user[0]=$result_user
   eval $pref\_system[0]=$result_system
   echo real: $result_real user: $result_user system: $result_system
}
  
io_test $stock_lua "slo" "-e os.exit(0)"
calculate_result "slo"
io_test $murgaLua "mlo" "-e os.exit(0)"
calculate_result "mlo"
io_test $stock_lua "sl" $luascript $filename $blocksize
calculate_result "sl"
io_test $murgaLua "ml" $luascript $filename $blocksize
calculate_result "ml"
echo startup overhead: $(eval dc -e \"5 k ${mlo_real[0]} ${slo_real[0]} - p\")"s" which is a $(eval dc -e \"5 k ${mlo_real[0]} ${slo_real[0]} / p\") times overhead
echo average file copy time for stock lua is: ${sl_real[0]} and for murgaLua: ${ml_real[0]} which is a $(eval dc -e \"5 k ${ml_real[0]} ${mlo_real[0]} - ${sl_real[0]} ${slo_real[0]} - / 1 - 100 *p\") "% overhead"


as what you want.

The io_speed.lua is from an earlier experiment and copies a file to /dev/null (so it is Unix specific).

I also wrote a small bash script to test it out, because I found a kernel bug on my system when I tested it today. It should work on any linux system (if dc is installed).

Juergen

03-24-2008 06:57 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
murgaLua CGI %ENV - dvw86 - 03-23-2008, 06:42 AM
RE: murgaLua CGI %ENV - Juergen - 03-23-2008, 08:30 AM
RE: murgaLua CGI %ENV - dvw86 - 03-23-2008, 09:25 AM
RE: murgaLua CGI %ENV - Juergen - 03-23-2008, 09:48 AM
RE: murgaLua CGI %ENV - dvw86 - 03-23-2008, 10:40 AM
RE: murgaLua CGI %ENV - JohnMurga - 03-23-2008, 08:17 PM
RE: murgaLua CGI %ENV - dvw86 - 03-24-2008, 03:39 AM
RE: murgaLua CGI %ENV - JohnMurga - 03-24-2008, 04:04 AM
RE: murgaLua CGI %ENV - dvw86 - 03-24-2008, 06:29 AM
RE: murgaLua CGI %ENV - asafp - 03-24-2008, 06:55 AM
RE: murgaLua CGI %ENV - Juergen - 03-24-2008 06:57 AM
RE: murgaLua CGI %ENV - JohnMurga - 03-24-2008, 07:11 AM
RE: murgaLua CGI %ENV - Juergen - 03-25-2008, 05:55 AM
RE: murgaLua CGI %ENV - mikshaw - 04-12-2008, 12:51 PM
RE: murgaLua CGI %ENV - JohnMurga - 04-14-2008, 03:36 AM
RE: murgaLua CGI %ENV - Juergen - 04-15-2008, 01:30 AM
RE: murgaLua CGI %ENV - JohnMurga - 04-15-2008, 07:28 AM
RE: murgaLua CGI %ENV - dvw86 - 05-20-2012, 02:45 AM
RE: murgaLua CGI %ENV - JohnMurga - 05-28-2012, 04:51 AM
RE: murgaLua CGI %ENV - jpjacobs - 05-28-2012, 07:35 AM
RE: murgaLua CGI %ENV - dvw86 - 05-29-2012, 01:55 AM
RE: murgaLua CGI %ENV - JohnMurga - 05-30-2012, 08:52 PM
RE: murgaLua CGI %ENV - dvw86 - 06-02-2012, 12:27 PM
RE: murgaLua CGI %ENV - dvw86 - 06-02-2012, 12:50 PM
RE: murgaLua CGI %ENV - JohnMurga - 06-02-2012, 04:46 PM
RE: murgaLua CGI %ENV - dvw86 - 06-03-2012, 04:48 AM
RE: murgaLua CGI %ENV - dvw86 - 06-03-2012, 05:13 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: