Skip to content

Commit a051660

Browse files
committed
update test case for slua and tolua
1 parent fca37ff commit a051660

5 files changed

Lines changed: 4 additions & 52 deletions

File tree

slua-1.7.0/Assets/benchmark/Resources/benchmark.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
2-
if not UnityEngine.GameObject then
3-
error("Click Make/All to generate lua wrap file")
4-
end
5-
61
local Vector3 = UnityEngine.Vector3
72
local GameObject = UnityEngine.GameObject
83
local Profiler = UnityEngine.Profiler
@@ -12,9 +7,6 @@ local Texture2D = UnityEngine.Texture2D
127
local Quaternion = UnityEngine.Quaternion
138
local SkinnedMeshRenderer = UnityEngine.SkinnedMeshRenderer
149

15-
function main()
16-
print(jit and "jit on" or "jit off, pls run test with luajit")
17-
end
1810

1911
local cube = GameObject("Script cube")
2012

slua-1.7.0/Assets/benchmark/benchmark.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void OnGUI()
8282
UnityEngine.Profiling.Profiler.EndSample();
8383
}
8484

85-
if (GUI.Button(new Rect(200, 100, 120, 50), "Test6 jit"))
85+
if (GUI.Button(new Rect(200, 100, 120, 50), "Test6"))
8686
{
8787
logText = "";
8888
var func = LuaSvr.mainState.getFunction("test6");
@@ -91,15 +91,6 @@ void OnGUI()
9191
UnityEngine.Profiling.Profiler.EndSample();
9292
}
9393

94-
if (GUI.Button(new Rect(200, 200, 120, 50), "Test6 non-jit"))
95-
{
96-
logText = "";
97-
var func = LuaSvr.mainState.getFunction("test7");
98-
UnityEngine.Profiling.Profiler.BeginSample("test7");
99-
func.call();
100-
UnityEngine.Profiling.Profiler.EndSample();
101-
}
102-
10394
GUI.Label(new Rect(Screen.width / 2, 0, Screen.width / 2, Screen.height), logText);
10495
}
10596
}

tolua-1.0.8.591/Assets/benchmark/Resources/Lua/benchmark.lua.bytes

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
2-
if not UnityEngine.GameObject then
3-
error("Click Lua/Generate All to generate wrap files")
4-
end
5-
61
local Vector3 = UnityEngine.Vector3
72
local GameObject = UnityEngine.GameObject
83
local Profiler = UnityEngine.Profiler
@@ -12,10 +7,6 @@ local Texture2D = UnityEngine.Texture2D
127
local Quaternion = UnityEngine.Quaternion
138
local SkinnedMeshRenderer = UnityEngine.SkinnedMeshRenderer
149

15-
function main()
16-
print(jit and "jit on" or "jit off, pls run test with luajit")
17-
end
18-
1910
local cube = GameObject.New("Script cube")
2011

2112

@@ -65,8 +56,6 @@ function test5()
6556
local v = GameObject.New()
6657
v:AddComponent(tp)
6758
local c=v:GetComponent(tp)
68-
c.shadowCastingMode = c.shadowCastingMode
69-
c.receiveShadows=false
7059
end
7160
print("test5/lua " .. (os.clock() - start));
7261
end
@@ -78,16 +67,5 @@ function test6()
7867
local t=Quaternion.Euler(100,100,100)
7968
local q=Quaternion.Slerp(Quaternion.identity,t,0.5)
8069
end
81-
print("test6/lua jit " .. (os.clock() - start));
82-
end
83-
84-
function test7()
85-
local transform=cube.transform
86-
local Quaternion = (jit and Quaternion.__raw) or Quaternion
87-
local start = os.clock()
88-
for i=1,200000 do
89-
local t=Quaternion.Euler(100,100,100)
90-
local q=Quaternion.Slerp(Quaternion.identity,t,0.5)
91-
end
92-
print("test6/lua non-jit " .. (os.clock() - start));
93-
end
70+
print("test6/lua " .. (os.clock() - start));
71+
end

tolua-1.0.8.591/Assets/benchmark/benchmark.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void OnGUI()
9191
UnityEngine.Profiling.Profiler.EndSample();
9292
}
9393

94-
if (GUI.Button(new Rect(200, 100, 120, 50), "Test6 jit"))
94+
if (GUI.Button(new Rect(200, 100, 120, 50), "Test6"))
9595
{
9696
logText = "";
9797
var func = _luaState.GetFunction("test6");
@@ -100,15 +100,6 @@ void OnGUI()
100100
UnityEngine.Profiling.Profiler.EndSample();
101101
}
102102

103-
if (GUI.Button(new Rect(200, 200, 120, 50), "Test6 non-jit"))
104-
{
105-
logText = "";
106-
var func = _luaState.GetFunction("test7");
107-
UnityEngine.Profiling.Profiler.BeginSample("test7");
108-
func.Call();
109-
UnityEngine.Profiling.Profiler.EndSample();
110-
}
111-
112103
GUI.Label(new Rect(Screen.width / 2, 0, Screen.width / 2, Screen.height), logText);
113104
}
114105
}
516 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)