Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

rate my code prog?

Name: Anonymous 2011-09-24 11:08

rate my code prog?



function nfa:translate_state_numbers(offset)
  self.transition_table = t.remap(self.transition_table,
                                  function(i,transitions)
                                    return i + offset
                                  end,
                                  function(i,transitions)
                                    return t.map(transitions,
                                                 function(state_set)
                                                   return t.map_keys(state_set,
                                                                     function(state_number)
                                                                       return state_number + offset
                                                                     end)
                                                 end)
                                  end)
  self.state_status_table = t.map_keys(self.state_status_table,
                                       function(state_number)
                                         return state_number + offset
                                       end)
  self.start_state = t.map_keys(self.start_state,
                                function(state_number)
                                  return state_number + offset
                                end)
end

Name: Anonymous 2011-09-24 14:45

>>14

thanks for the tip, but after making the change, lua is still fasta:


lua-fan@luaisdabest>>cat loop.lua
#!/usr/bin/lua

for i=1,10000000 do
end
lua-fan@luaisdabest>>cat loop.py
#!/usr/bin/python

for i in xrange(10000000): pass
lua-fan@luaisdabest>>time loop.lua

real    0m0.877s
user    0m0.852s
sys     0m0.004s
lua-fan@luaisdabest>>time loop.py

real    0m6.677s
user    0m6.616s
sys     0m0.036s
lua-fan@luaisdabest>>scm
SCM version 5e5, Copyright (C) 1990-2006 Free Software Foundation.
SCM comes with ABSOLUTELY NO WARRANTY; for details type `(terms)'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `(terms)' for details.
;loading /usr/share/slib/require
;done loading /usr/share/slib/require.scm
;loading /usr/share/slib/require
;done loading /usr/share/slib/require.scm
;loading /usr/lib/scm/Link
;done loading /usr/lib/scm/Link.scm
;loading /usr/lib/scm/Transcen
;done loading /usr/lib/scm/Transcen.scm
(define lua_times '(.877 .852 .004))
#<unspecified>
(define python_times '(6.677 6.616 .036))
#<unspecified>
(define lua-is-better (map / python_times lua_times))
#<unspecified>
lua-is-better
(7.6134549600912215 7.765258215962441 9.0)
`(python uses ,(car lua-is-better) times more real "time,"
              ,(cadr lua-is-better) times more user "time,"
          and ,(caddr lua-is-better) times more system "time!")
(python uses 7.6134549600912215 times more real "time," 7.765258215962441 times more user "time," and 9.0 times more system "time!")

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List