name = 'timestamp', type = 'number' },
{ name = 'price', type = 'decimal' },
{ name = 'volume_test1_integral', type = 'decimal' },
{ name = 'volume_test2_integral', type = 'decimal' },
}})
s:create_index('pk')
clock = require('clock')
tup = s:insert({clock.time(), decimal.new('0.00001'), decimal.new('0.00001'), decimal.new('0.00001')})
t1 = clock.monotonic()
-- access by index
for i = 1, 100000 do tmp = tup[4] end
t2 = clock.monotonic()
-- access by name
for i = 1, 100000 do tmp = tup.volume_test1_integral end
t3 = clock.monotonic()
-- wtf?
string.format('ind: %s, name: %s', t2 - t1, t3 - t2)
Так ведь [4] - это volume_test2, а не 1
Обсуждают сегодня