Esempio n. 1
0
    private void Test()
    {
        int count = 100;

        System.Diagnostics.Stopwatch watch;
        Vector3[] randomPoints = new Vector3[count];
        for (int i = 0; i < randomPoints.Length; i++)
        {
            randomPoints[i] = Random.insideUnitSphere * radius;
        }
        watch = System.Diagnostics.Stopwatch.StartNew();
        for (int i = 0; i < randomPoints.Length - 1; i++)
        {
            graph.FindNearestIdBruteForce(randomPoints[i]);
        }
        watch.Stop();
        Debug.Log("Find nearest brute force for " + randomPoints.Length + " randomPoints for " + (watch.ElapsedMilliseconds / 1000f));

        int[] points = new int[count];
        for (int i = 0; i < points.Length; i++)
        {
            points[i] = UnityEngine.Random.Range(0, graph.Nodes.Length);
        }

        watch = System.Diagnostics.Stopwatch.StartNew();
        for (int i = 0; i < points.Length - 1; i++)
        {
            graph.FindPathDijkstra(points[i], points[i + 1]);
        }
        watch.Stop();
        Debug.Log("Find path Dijkstra for " + points.Length + " points for " + (watch.ElapsedMilliseconds / 1000f));
        watch = System.Diagnostics.Stopwatch.StartNew();
        for (int i = 0; i < points.Length - 1; i++)
        {
            graph.FindPathAStar(points[i], points[i + 1]);
        }
        watch.Stop();
        Debug.Log("Find path AStar for " + points.Length + " points for " + (watch.ElapsedMilliseconds / 1000f));
    }