Skip to content

Instantly share code, notes, and snippets.

@JunShimura
Last active May 21, 2019 13:50
Show Gist options
  • Save JunShimura/b7c88cd0c7e84eaa6e4bc5f223cd0ec1 to your computer and use it in GitHub Desktop.
Save JunShimura/b7c88cd0c7e84eaa6e4bc5f223cd0ec1 to your computer and use it in GitHub Desktop.
RandomTest.cs
using UnityEngine;
using UnityEngine.TestTools;
using NUnit.Framework;
using System.Collections;
public class RandomTestScript
{
[Test]
public void RandomTestScriptSimplePasses()
{
// Use the Assert class to test conditions.
// https://docs.unity3d.com/ja/current/ScriptReference/Random.Range.html
int resultInt = 0;
int resultFloat = 0;
float floatR = 0;
int intR = 0;
float time = Time.realtimeSinceStartup;
for (int i = 0; i < 1000000000; i++)
{
floatR = Random.Range(0.0f, 100.0f);
if (floatR < 20.0f)
{
resultFloat++;
}
}
Debug.Log( "処理時間:"+(Time.realtimeSinceStartup - time));
Debug.Log(resultFloat);
time = Time.realtimeSinceStartup;
for (int i = 0; i < 1000000000; i++)
{
intR = Random.Range(0, 10);
if (intR < 2)
{
resultInt++;
}
}
Debug.Log("処理時間:" + (Time.realtimeSinceStartup - time));
Debug.Log(resultInt);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment