fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4.  
  5. public class Program
  6. {
  7. private static string Test(int n, string s)
  8. {
  9. var res = "";
  10.  
  11. for (var q=0; q<n; ++q)
  12. res += s;
  13.  
  14. return res;
  15. }
  16.  
  17. public static void Main()
  18. {
  19. var res = new Dictionary<string, double>[10];
  20. const int N = 1024;
  21. var sw = new Stopwatch();
  22.  
  23. for (var n=0; n<res.Length; ++n)
  24. {
  25. res[n] = new Dictionary<string, double>();
  26.  
  27. foreach (var s in new string[] {"!", "!2", "!234", "!2345678"})
  28. {
  29. res[n][s] = 0;
  30.  
  31. for (var q=0; q<N; ++q)
  32. {
  33. sw.Restart();
  34. Test(1 << n, s);
  35. sw.Stop();
  36. res[n][s] += sw.ElapsedTicks;
  37. }
  38.  
  39. res[n][s] /= N;
  40. }
  41. }
  42.  
  43. for (var n=0; n<res.Length; ++n)
  44. {
  45. Console.Write("{0,2} {1,7} ", n, 1<<n);
  46.  
  47. foreach (var kvp in res[n])
  48. Console.Write("{0,10:0.000} ", kvp.Value / 1000);
  49.  
  50. Console.WriteLine();
  51. }
  52. }
  53. }
Success #stdin #stdout 1.23s 131648KB
stdin
Standard input is empty
stdout
 0       1      0.001      0.000      0.000      0.000 
 1       2      0.002      0.001      0.001      0.001 
 2       4      0.003      0.003      0.005      0.003 
 3       8      0.006      0.006      0.007      0.007 
 4      16      0.013      0.015      0.013      0.014 
 5      32      0.025      0.025      0.032      0.034 
 6      64      0.050      0.059      0.070      0.097 
 7     128      0.120      0.142      0.220      0.303 
 8     256      0.337      0.417      0.630      0.972 
 9     512      0.897      1.256      1.964      4.087