Last active
November 23, 2016 12:53
-
-
Save culurciello/ac9307197db6f451c19bfb726a35f448 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- E. Culurciello, November 2016 | |
-- test to see if table insert/remove is slower than table addressing | |
iters = 1e5 | |
tablesize = 1e4 | |
tab1={} | |
item = torch.randn(iters,1024) | |
sys.tic() | |
for i=1,iters do | |
if i>tablesize then table.remove(tab1,1) end | |
table.insert(tab1, item[i]:clone()) | |
end | |
print('table insert', sys.toc()) | |
tabIdx = 1 | |
sys.tic() | |
for i=1,iters do | |
tab1[tabIdx%tablesize+1] = item[i]:clone() | |
tabIdx = tabIdx + 1 | |
end | |
print('table address', sys.toc()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment