Advertisement
funny_falcon

test_gc.lua

Oct 14th, 2013
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.49 KB | None | 0 0
  1. local mode = ...
  2. mode = mode and tonumber(mode) or 1
  3.  
  4. local ffi = require 'ffi'
  5. ffi.cdef 'struct ss{ int i ; }'
  6. local ss_t = ffi.typeof('struct ss')
  7. local noop = function(t) end
  8. if mode == 1 then
  9.     local mtt = {__gc=noop}
  10.     ffi.metatype(ss_t, mtt)
  11. end
  12. for i=1,20000000 do
  13.     if mode == 1 then
  14.         local g = ffi.new(ss_t)
  15.     elseif mode == 2 then
  16.         local g = ffi.new(ss_t)
  17.         ffi.gc(g, noop)
  18.     elseif mode == 3 then
  19.         local g = ffi.new(ss_t)
  20.     end
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement