Skip to content

v0.8.0f5 #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@



# JENGINE v0.8.0f4
# JENGINE v0.8.0f5

**JEngine is an out-of-the-box framework designed for Unity developers. It encapsulates powerful functions. Beginners can also get started quickly and easily create games that can be updated in runtime.**

Expand Down
2 changes: 1 addition & 1 deletion README_zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@



# JENGINE v0.8.0f4
# JENGINE v0.8.0f5

JEngine是针对Unity开发者设计的**开箱即用**的框架,封装了强大的功能,小白也能**快速上手**,**轻松制作**可以**热更新的游戏**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ public static void DoBind(ICollection<ClassBind> cbs)

cb.Active(data);
}

Object.Destroy(cb);
}

//确保任务全执行了
Expand Down
14 changes: 0 additions & 14 deletions UnityProject/Assets/Dependencies/JEngine/Core/Util/ClassBind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,22 +496,8 @@ public void Active(ClassData classData)
{
((MonoBehaviour)clrInstance).enabled = true;
classData.Activated = true;
Remove();
});
}
else
{
Remove();
}
}

/// <summary>
/// Remove cb
/// </summary>
private void Remove()
{
//添加后删除
Destroy(this);
}


Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions UnityProject/HotUpdateScripts/HotUpdateScripts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<Compile Include="JEngine\Core\JValidation.cs" />
<Compile Include="JEngine\Examples\Core\ValidationDemo.cs" />
<Compile Include="JEngine\Examples\Core\AddOnDemo.cs" />
<Compile Include="JEngine\Examples\Core\Test.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="UnityEngine.UIModule">
Expand Down
4 changes: 3 additions & 1 deletion UnityProject/HotUpdateScripts/JEngine/Core/JBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ private static string AddClassBind(GameObject gameObject, bool activeAfter, Type
activeAfter = activeAfter,
};
var id = ((JBehaviour)cb.AddClass(cd))._instanceID;
cb.BindSelf();
cb.Active(cd);
UnityEngine.Object.Destroy(cb);
LifeCycleMgr.Instance.ExecuteOnceTask();
return id;
}

Expand Down
158 changes: 158 additions & 0 deletions UnityProject/HotUpdateScripts/JEngine/Examples/Core/Test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
//
// Test.cs
//
// Author:
// JasonXuDeveloper(傑) <jasonxudeveloper@gmail.com>
//
// Copyright (c) 2023 JEngine
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using ILRuntime.Runtime;
using System.Diagnostics;
using Debug = UnityEngine.Debug;

namespace HotUpdateScripts
{


/// <summary>
/// 测试dll优化
/// </summary>
public class Test
{
public void DoTest()
{
Debug.Log($"original(1) = {Original(1)}");
Debug.Log($"jit(1) = {JIT(1)}");
Debug.Log($"optimized(1) = {Optimized(1)}");
Debug.Log($"optimizedJIT(1) = {OptimizedJIT(1)}");
RunTest(10);
RunTest(100);
RunTest(1000);
RunTest(10000);
RunTest(100000);
}

public void RunTest(int cnt = 100000)
{
Stopwatch sw = new Stopwatch();
Debug.Log($"{cnt}次计算");
sw.Start();
int a = 0;
int i = cnt;
while (i-- > 0)
{
a = Original(i);
}

sw.Stop();
Debug.Log($"Original: {sw.ElapsedMilliseconds}ms");

sw.Restart();
i = cnt;
while (i-- > 0)
{
a = JIT(i);
}

sw.Stop();
Debug.Log($"JIT: {sw.ElapsedMilliseconds}ms");

sw.Restart();
i = cnt;
while (i-- > 0)
{
a = Optimized(i);
}

sw.Stop();
Debug.Log($"Optimized: {sw.ElapsedMilliseconds}ms");

sw.Restart();
i = cnt;
while (i-- > 0)
{
a = OptimizedJIT(i);
}

sw.Stop();
Debug.Log($"OptimizedJIT: {sw.ElapsedMilliseconds}ms");
}

public int Original(int x)
{
int a = 5;
int b = 20;
int c = 10;
c = a;
int d = 5 * a;
int e = d;
int f = e / 2;
int g = f + a + b + c * 6 - b / 4;
int h = x * 2 + 10 + 3 - 6 - 8 - g;
return h + 10 % 3;
}

[ILRuntimeJIT(ILRuntimeJITFlags.JITImmediately)]
public int JIT(int x)
{
int a = 5;
int b = 20;
int c = 10;
c = a;
int d = 5 * a;
int e = d;
int f = e / 2;
int g = f + a + b + c * 6 - b / 4;
int h = x * 2 + 10 + 3 - 6 - 8 - g;
return h + 10 % 3;
}

public int Optimized(int x)
{
int a = 5;
int b = 20;
int c = 10;
c = a;
int d = 5 * a;
int e = d;
int f = e / 2;
int g = f + a + b + c * 6 - b / 4;
int h = x * 2 + 10 + 3 - 6 - 8 - g;
return h + 10 % 3;
}

[ILRuntimeJIT(ILRuntimeJITFlags.JITImmediately)]
public int OptimizedJIT(int x)
{
int a = 5;
int b = 20;
int c = 10;
c = a;
int d = 5 * a;
int e = d;
int f = e / 2;
int g = f + a + b + c * 6 - b / 4;
int h = x * 2 + 10 + 3 - 6 - 8 - g;
return h + 10 % 3;
}
}
}

128 changes: 1 addition & 127 deletions UnityProject/HotUpdateScripts/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System.Diagnostics;
using ILRuntime.Runtime;
using JEngine.Core;
using Debug = UnityEngine.Debug;
using UnityEngine;

namespace HotUpdateScripts
{
Expand Down Expand Up @@ -55,127 +52,4 @@ public static void RunGame()
//的方法一,把生成的平台改成Any CPU(默认是小写的,windows下无法生成)
}
}

/// <summary>
/// 测试dll优化
/// </summary>
public class Test
{
public void DoTest()
{
Debug.Log($"original(1) = {Original(1)}");
Debug.Log($"jit(1) = {JIT(1)}");
Debug.Log($"optimized(1) = {Optimized(1)}");
Debug.Log($"optimizedJIT(1) = {OptimizedJIT(1)}");
RunTest(10);
RunTest(100);
RunTest(1000);
RunTest(10000);
RunTest(100000);
}

public void RunTest(int cnt = 100000)
{
Stopwatch sw = new Stopwatch();
Debug.Log($"{cnt}次计算");
sw.Start();
int a = 0;
int i = cnt;
while (i-- > 0)
{
a = Original(i);
}

sw.Stop();
Debug.Log($"Original: {sw.ElapsedMilliseconds}ms");

sw.Restart();
i = cnt;
while (i-- > 0)
{
a = JIT(i);
}

sw.Stop();
Debug.Log($"JIT: {sw.ElapsedMilliseconds}ms");

sw.Restart();
i = cnt;
while (i-- > 0)
{
a = Optimized(i);
}

sw.Stop();
Debug.Log($"Optimized: {sw.ElapsedMilliseconds}ms");

sw.Restart();
i = cnt;
while (i-- > 0)
{
a = OptimizedJIT(i);
}

sw.Stop();
Debug.Log($"OptimizedJIT: {sw.ElapsedMilliseconds}ms");
}

public int Original(int x)
{
int a = 5;
int b = 20;
int c = 10;
c = a;
int d = 5 * a;
int e = d;
int f = e / 2;
int g = f + a + b + c * 6 - b / 4;
int h = x * 2 + 10 + 3 - 6 - 8 - g;
return h + 10 % 3;
}

[ILRuntimeJIT(ILRuntimeJITFlags.JITImmediately)]
public int JIT(int x)
{
int a = 5;
int b = 20;
int c = 10;
c = a;
int d = 5 * a;
int e = d;
int f = e / 2;
int g = f + a + b + c * 6 - b / 4;
int h = x * 2 + 10 + 3 - 6 - 8 - g;
return h + 10 % 3;
}

public int Optimized(int x)
{
int a = 5;
int b = 20;
int c = 10;
c = a;
int d = 5 * a;
int e = d;
int f = e / 2;
int g = f + a + b + c * 6 - b / 4;
int h = x * 2 + 10 + 3 - 6 - 8 - g;
return h + 10 % 3;
}

[ILRuntimeJIT(ILRuntimeJITFlags.JITImmediately)]
public int OptimizedJIT(int x)
{
int a = 5;
int b = 20;
int c = 10;
c = a;
int d = 5 * a;
int e = d;
int f = e / 2;
int g = f + a + b + c * 6 - b / 4;
int h = x * 2 + 10 + 3 - 6 - 8 - g;
return h + 10 % 3;
}
}
}
6 changes: 3 additions & 3 deletions UnityProject/UserSettings/EditorUserSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ EditorUserSettings:
serializedVersion: 4
m_ConfigSettings:
RecentlyUsedScenePath-0:
value: 2242470311464673021a393214224b1524120b25393a25353e663c37e6cf3a69add435ece93f70283c11fb721130082beb
value: 22424703114646720307186c052d56040f
flags: 0
RecentlyUsedScenePath-1:
value: 2242470311464673021a393214224b1524120b25393a25353e663032ebee7b0be1e238eca81d3e313c4cfa320d2a18
value: 2242470311464673021a393214224b1524120b25393a25353e663c37e6cf3a69add435ece93f70283c11fb721130082beb
flags: 0
RecentlyUsedScenePath-2:
value: 22424703114646720307186c052d56040f
value: 2242470311464673021a393214224b1524120b25393a25353e663032ebee7b0be1e238eca81d3e313c4cfa320d2a18
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.jasonxudeveloper.jengine",
"version": "0.8.0f4",
"version": "0.8.0f5",
"displayName": "JEngine",
"description": "The solution that allows unity games update in runtime.",
"license": "MIT",
Expand Down