关于大量字符串连接 (速度提升100倍)123456789101112131415161718a = os.clock()local s = ''for i=1,100000 do s = s .. 'a'endb = os.clock()print(b-a) -- 1.708秒a = os.clock()local s = ''local t = {}for i=1,100000 do t[#t+1] = 'a'ends = table.concat(t,'')b = os.clock()print(b-a) -- 0.011秒 关于创建大量小size的表(大概速度提升1倍)12345678910111213141516-- 创建大量小size表时,应该先填充好表的大小a = os.clock()for i=1,2000000 do local a = {} a[1] = 1;a[2] = 2;a[3] = 3endb = os.clock()print(b-a) -- 1.361秒a = os.clock()for i=1,2000000 do local a = {0,0,0} a[1] = 1;a[2] = 2;a[3] = 3endb = os.clock()print(b-a) -- 0.623秒