Exemplo n.º 1
0
    // [MenuItem("Window/pb_Profiler Test")]
    public static void Init()
    {
        Stopwatch stopwatch = new Stopwatch();

        stopwatch.Start();

        for (int i = 0; i < ITERATIONS; i++)
        {
            Thread.Sleep(SLEEP);
        }
        stopwatch.Stop();

        pb_Profiler profiler = new pb_Profiler("pb_Profiler Tests");

        profiler.BeginSample("Sleep");
        for (int i = 0; i < ITERATIONS; i++)
        {
            profiler.BeginSample("Thread.Sleep");
            Thread.Sleep(SLEEP);
            profiler.EndSample();
        }
        profiler.EndSample();

        profiler.EndSample();

        long s_sum = stopwatch.ElapsedMilliseconds;
        long p_sum = profiler.GetRootSample().sum;

        if (System.Math.Abs(p_sum - s_sum) > MAX_SUM_DELTA)
        {
            UE.Debug.LogError("Stopwatch: " + s_sum + "\nProfiler: " + s_sum);
        }
        else
        {
            UE.Debug.Log("Stopwatch: " + s_sum + "\nProfiler: " + s_sum);
        }
    }
Exemplo n.º 2
0
 public static bool GeneratePolygonCrosshatch(pb_Profiler profiler, Vector2[] polygon, float scale, Color color, int lineSpacing, ref Texture2D texture)
Exemplo n.º 3
0
	public static void Run()
	{
		// Run some intensive calculations an time them.

		pb_Profiler profiler = new pb_Profiler();
		float[] rand = new float[SAMPLE_COUNT];
		bool superBreak = false;

		profiler.BeginSample("Run CPU Intensive Tasks");

		profiler.BeginSample("Generate Random Numbers");
		{
			for(int i = 0; i < SAMPLE_COUNT; i++)
			{
				profiler.BeginSample("Show Progress Bar");
				if( EditorUtility.DisplayCancelableProgressBar("Doing some CPU intensive tasks...", "Generating lots of random numbers.", (i/(float)SAMPLE_COUNT) / 2f) )
				{
					superBreak = true;
					break;
				}
				profiler.EndSample();

				profiler.BeginSample("Random.Range");
				rand[i] = Random.Range(0f, 1000f);
				profiler.EndSample();
			}
		}
		profiler.EndSample();
		

		profiler.BeginSample("Do Math with Random Numbers");
		{
			for(int i = 0; i < SAMPLE_COUNT-3; i++)
			{
				profiler.BeginSample("Show Progress Bar");
				if( EditorUtility.DisplayCancelableProgressBar("Doing some CPU intensive tasks...", "Generating lots of random numbers.", ((i/(float)SAMPLE_COUNT) / 2f) + .5f) || superBreak)
					break;
				profiler.EndSample();

				profiler.BeginSample("Allocate Vector3");
				Vector3 v0 = new Vector3(	rand[i+0],
											rand[i+1],
											rand[i+2] );
				Vector3 v1 = new Vector3( 	rand[i+1],
											rand[i+2],
											rand[i+0] );
				profiler.EndSample();

				profiler.BeginSample("Cross -> Dot Product");
				
					profiler.BeginSample("Cross Product");
						Vector3 f = Vector3.Cross(v0, v1);
					profiler.EndSample();

					profiler.BeginSample("Dot Product");
						f.x = Vector3.Dot(f, v0);
					profiler.EndSample();

				profiler.EndSample();

				profiler.BeginSample("Normalize");
					f = Vector3.Normalize(v0);
				profiler.EndSample();
			}
		}
		EditorUtility.ClearProgressBar();

		profiler.EndSample();	// </Do Math>

		profiler.EndSample();	// </Run CPU>

		Debug.Log(profiler.ToString());
	}
Exemplo n.º 4
0
    public static void Run()
    {
        // Run some intensive calculations an time them.

        pb_Profiler profiler = new pb_Profiler("Demo");

        float[] rand       = new float[SAMPLE_COUNT];
        bool    superBreak = false;

        profiler.BeginSample("Run CPU Intensive Tasks");

        profiler.BeginSample("Generate Random Numbers");
        {
            for (int i = 0; i < SAMPLE_COUNT; i++)
            {
                profiler.BeginSample("Show Progress Bar");
                if (EditorUtility.DisplayCancelableProgressBar("Doing some CPU intensive tasks...", "Generating lots of random numbers.", (i / (float)SAMPLE_COUNT) / 2f))
                {
                    superBreak = true;
                    break;
                }
                profiler.EndSample();

                profiler.BeginSample("Random.Range");
                rand[i] = Random.Range(0f, 1000f);
                profiler.EndSample();
            }
        }
        profiler.EndSample();


        profiler.BeginSample("Do Math with Random Numbers");
        {
            for (int i = 0; i < SAMPLE_COUNT - 3; i++)
            {
                profiler.BeginSample("Show Progress Bar");
                if (EditorUtility.DisplayCancelableProgressBar("Doing some CPU intensive tasks...", "Generating lots of random numbers.", ((i / (float)SAMPLE_COUNT) / 2f) + .5f) || superBreak)
                {
                    break;
                }
                profiler.EndSample();

                profiler.BeginSample("Allocate Vector3");
                Vector3 v0 = new Vector3(rand[i + 0],
                                         rand[i + 1],
                                         rand[i + 2]);
                Vector3 v1 = new Vector3(rand[i + 1],
                                         rand[i + 2],
                                         rand[i + 0]);
                profiler.EndSample();

                profiler.BeginSample("Cross -> Dot Product");

                profiler.BeginSample("Cross Product");
                Vector3 f = Vector3.Cross(v0, v1);
                profiler.EndSample();

                profiler.BeginSample("Dot Product");
                f.x = Vector3.Dot(f, v0);
                profiler.EndSample();

                profiler.EndSample();

                profiler.BeginSample("Normalize");
                f = Vector3.Normalize(v0);
                profiler.EndSample();
            }
        }
        EditorUtility.ClearProgressBar();

        profiler.EndSample();           // </Do Math>

        profiler.EndSample();           // </Run CPU>

        Debug.Log(profiler.ToString());
    }