1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Dictionary<int, int> intpairs = new Dictionary<int, int>(); intpairs.Add(1, 1); Dictionary<string, int> strpairs = new Dictionary<string, int>(); strpairs.Add("test", 1); const int time = 1000000; using (new ProfilerScope("int")) { stopwatch.Start(); for (int i = 0; i < time; i++) { var res = intpairs[1]; } stopwatch.Stop(); inttime.text = stopwatch.ElapsedMilliseconds.ToString(); }
using (new ProfilerScope("string")) { stopwatch.Restart(); for (int i = 0; i < time; i++) { var res = strpairs["test"]; } stopwatch.Stop(); stringtime.text = stopwatch.ElapsedMilliseconds.ToString(); }
|