Iii. execution speed of Squirrel
It is worth noting that the execution speed of Squirrel is slow. Lua is always fast. Can Squirrel inherit and carry forward this feature? It is hard to say that the authors of Squirrel are not good at comparison, because Squirrel adds many new features. The authors say that the built-in Array of Squirrel must be faster than the Array simulated by Table in Lua (I don't think so, see my test results ).
I didn't specifically test the speed of Lua and Squirrel, but I read a Blog about "cloud Wind", saying that the Lua virtual machine is well optimized and executed based on "registers". I didn't study the Lua source code, squirrel's source code is crude. The code executing the bytecode does not seem to be as fine as Lua. It is estimated that Squirrel's execution speed will be slower than Lua in the same case.
Although Squirrel may be slower than Lua, it is still a relatively fast scripting language. After all, its core idea is derived from Lua. In my 1.5G
On Laptop, an array is created and traversed at a speed of about 1/4 of C ++. The test code is as follows:
C ++:
Std: vector <int>
Arr;
For (int I = 0; I <1000; I ++) arr. push_back (I * 13 );
Int
Total = 0;
For (int
J = 0; j <1000; j ++) total + = arr [j];
Squirrel Array:
Local arr = [];
For (local I = 0; I <1000; I ++) arr. append (I * 13 );
Local total = 0;
For (local j = 0; j <1000; j ++) total + = arr [j];
Squirrel Table:
Local
Tb = {};
For (local I = 0; I <1000; I ++) tb [I] <-(I * 13 );
Local total2 = 0;
For (local j = 0; j <1000; j ++) total2 + = tb [j];
Tm. endClock ();
I used the TSC register inside the CPU for direct running time measurement (it should be one of the most precise running time measurement methods at present, 1.5 M CPU clock pulse for one millisecond), run the previous code, C ++ uses a 280 k cpu clock pulse, Squirrel Array uses a 1110 k cpu clock pulse, and Squirrel Table uses a 903 k cpu clock pulse.
This test is very interesting. Squirrel's Table is actually a little faster than Array, which is totally surprising to me.