Esempio n. 1
0
        private static void TestGeneratePawnx1000()
        {
            float[] array = new float[10]
            {
                10f,
                20f,
                50f,
                100f,
                200f,
                500f,
                1000f,
                2000f,
                5000f,
                1E+20f
            };
            int[] array2 = new int[array.Length];
            for (int i = 0; i < 1000; i++)
            {
                PawnKindDef random = DefDatabase <PawnKindDef> .GetRandom();

                PerfLogger.Reset();
                Pawn  pawn = PawnGenerator.GeneratePawn(random, FactionUtility.DefaultFactionFrom(random.defaultFactionType));
                float ms   = PerfLogger.Duration() * 1000f;
                array2[array.FirstIndexOf((float time) => ms <= time)]++;
                if (pawn.Dead)
                {
                    Log.Error("Pawn is dead");
                }
                Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
            }
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Pawn creation time histogram:");
            for (int j = 0; j < array2.Length; j++)
            {
                stringBuilder.AppendLine($"<{array[j]}ms: {array2[j]}");
            }
            Log.Message(stringBuilder.ToString());
        }
 public static void Flush()
 {
     Log.Message((PerfLogger.currentLog == null) ? string.Empty : PerfLogger.currentLog.ToString(), false);
     PerfLogger.Reset();
 }