1.0.0 • Published 6 months ago
com.elestrago.unity.runtime-benchmark v1.0.0
Runtime Benchmark
Installing
Using the native Unity Package Manager introduced in 2017.2, you can add this library as a package by modifying your
manifest.json
file found at /ProjectName/Packages/manifest.json
to include it as a dependency. See the example below
on how to reference it.
Install via OpenUPM
The package is available on the npmjs registry.
Add registry scope
{
"dependencies": {
...
"com.elestrago.unity.runtime-benchmark": "x.x.x",
...
},
"scopedRegistries": [
{
"name": "eLeSTRaGo",
"url": "https://registry.npmjs.org",
"scopes": [
"com.elestrago"
]
}
]
}
Usage
Import sample
Add sample from package to you project
// TODO: Screenshot
Create benchmark
Create you benchmark script in any place in project.
Use Preserve
attribute for avoid script splitting in IL2CPP
build backend.
Example script:
using RuntimeBenchmark;
using UnityEngine;
using UnityEngine.Scripting;
namespace Example
{
[Preserve]
[BenchmarkFixture]
public class ExampleBenchmarkBuilder : IBenchmarkBuilder
{
public BenchmarkGroup.Builder Build(BenchmarkGroup.Builder builder)
=> builder.SetName("Example")
.SetIterations()
.AddBenchmark<Benchmark>("Sum of vector3");
private class Benchmark : IBenchmark
{
public void Execute()
{
for (int i = 0; i < 1000; i++)
{
var result = new Vector3() + new Vector3();
}
}
}
}
}
Run on device
For run this on device make a BenchmarkScene
as default start scene
// TODO: Screenshot
1.0.0
6 months ago