fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Diagnostics;
  10.  
  11. namespace WindowsFormsApplication1
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19. private void Form1_Load(object sender, EventArgs e)
  20. {
  21.  
  22. }
  23.  
  24. private void button1_Click(object sender, EventArgs e)
  25. {
  26. textBox1.AppendText("test start" + Environment.NewLine);
  27. this.hoge1();
  28. this.hoge2();
  29. this.hoge3();
  30. this.hoge4();
  31. }
  32.  
  33. void hoge1()
  34. {
  35. Stopwatch sw = new Stopwatch();
  36. sw.Reset();
  37. sw.Start();
  38. for (int i = 0; i < 10; i++)
  39. {
  40. for (int r = 0; r < 100000; r++)
  41. {
  42. int R = r / 4; if (r % 4 == 1) R++;
  43. int G = r / 4; if (r % 4 == 2) G++;
  44. int B = r / 4; if (r % 4 == 3) B++;
  45. }
  46. }
  47. sw.Stop();
  48. textBox1.AppendText(
  49. ((double)sw.ElapsedTicks
  50. / (double)Stopwatch.Frequency).ToString()
  51. + Environment.NewLine);
  52. }
  53. void hoge2()
  54. {
  55. Stopwatch sw = new Stopwatch();
  56. sw.Reset();
  57. sw.Start();
  58. for (int i = 0; i < 10; i++)
  59. {
  60. for (int r = 0; r < 100000; r++)
  61. {
  62. int R = r >> 2; if ((r & 0x3) == 1) R++;
  63. int G = r >> 2; if ((r & 0x3) == 2) G++;
  64. int B = r >> 2; if ((r & 0x3) == 3) B++;
  65. }
  66. }
  67. sw.Stop();
  68. textBox1.AppendText(
  69. ((double)sw.ElapsedTicks
  70. / (double)Stopwatch.Frequency).ToString()
  71. + Environment.NewLine);
  72. }
  73. void hoge3()
  74. {
  75. Stopwatch sw = new Stopwatch();
  76. sw.Reset();
  77. sw.Start();
  78. for (int i = 0; i < 10; i++)
  79. {
  80.  
  81. for (int r = 0; r < 100000; r++)
  82. {
  83. int R = r / 4 + (r + 3) % 4 / 3;
  84. int G = r / 4 + (r + 2) % 4 / 3;
  85. int B = r / 4 + (r + 1) % 4 / 3;
  86. }
  87. }
  88. sw.Stop();
  89. textBox1.AppendText(
  90. ((double)sw.ElapsedTicks
  91. / (double)Stopwatch.Frequency).ToString()
  92. + Environment.NewLine);
  93. }
  94. void hoge4()
  95. {
  96. Stopwatch sw = new Stopwatch();
  97. sw.Reset();
  98. sw.Start();
  99. for (int i = 0; i < 10; i++)
  100. {
  101. for (int r = 0; r < 100000; r++)
  102. {
  103. int R = (r >> 2) + ((r + 3) & 0x3) / 3;
  104. int G = (r >> 2) + ((r + 2) & 0x3) / 3;
  105. int B = (r >> 2) + ((r + 1) & 0x3) / 3;
  106. }
  107. }
  108. sw.Stop();
  109. textBox1.AppendText(
  110. ((double)sw.ElapsedTicks
  111. / (double)Stopwatch.Frequency).ToString()
  112. + Environment.NewLine);
  113. }
  114. }
  115. }
  116.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty