Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Pathfinding;
- using System.Collections.Generic;
- using UnityEngine;
- namespace JustAnotherNamespace
- {
- public class BoundsProfile : MonoBehaviour
- {
- private bool Intersects (Bounds b1, Bounds b2)
- {
- Vector3 min1 = b1.min;
- Vector3 max1 = b1.max;
- Vector3 min2 = b2.min;
- Vector3 max2 = b2.max;
- return min1.x <= max2.x && max1.x >= min2.x && min1.y <= max2.y && max1.y >= min2.y && min1.z <= max2.z && max1.z >= min2.z;
- }
- public void Start () {
- int seed = UnityEngine.Random.seed;
- Profile prof1 = new Profile("U bounds");
- Profile prof2 = new Profile("U2 bounds");
- for (int test=0;test<10;test++) {
- int c = 0;
- System.Random rnd = new System.Random(seed);
- c = 0;
- prof1.Start();
- for (int q=0;q<10;q++) {
- Bounds b1 = new Bounds(rnd.Next(10)*Vector3.one, rnd.Next(10)*Vector3.one);
- Bounds b2 = new Bounds(rnd.Next(10)*Vector3.one, rnd.Next(10)*Vector3.one);
- for (int i=0;i<100000;i++) {
- if (b1.Intersects(b2)) {
- c++;
- }
- }
- }
- prof1.Stop(c);
- rnd = new System.Random(seed);
- c = 0;
- prof2.Start();
- for (int q=0;q<10;q++) {
- Bounds b1 = new Bounds(rnd.Next(10)*Vector3.one, rnd.Next(10)*Vector3.one);
- Bounds b2 = new Bounds(rnd.Next(10)*Vector3.one, rnd.Next(10)*Vector3.one);
- for (int i=0;i<100000;i++) {
- if (Intersects(b1,b2)) {
- c++;
- }
- }
- }
- prof2.Stop(c);
- }
- prof1.Log();
- prof2.Log();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement