.[ ČeskéHry.cz ].

Laboratoř ČeskýchHer.cz - PasteBin

Vložit nový kód

ČeskéHry.cz - KOMUNITA HERNÍCH VÝVOJÁŘŮ

  1. 2026110811h44min56sec
    4 min
  2. 2026110811h39min55sec
    10 min
  3. 2026110811h34min50sec
    15 min
  4. 2026110811h29min48sec
    20 min
  5. 2026110811h24min47sec
    25 min
  6. 2026110811h19min45sec
    30 min
  7. 2026110811h14min45sec
    35 min
  8. 2026110811h09min29sec
    40 min
  9. ČPx MEGA LINKS 2026 VIP - ČPx COLLECTIONS
    44 min
  10. ČPx MEGA LINKS 2026 VIP - ČPx COLLECTIONS
    44 min
Link: http://nopaste.ceske-hry.cz/subdom/nopaste222806
Jazyk: C#
Vloženo: 16.12.2009, 22:36
Stáhnout jako soubor
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6.  
  7. namespace PixelTest
  8. {
  9. class Program
  10. {
  11. unsafe static void Main(string[] args)
  12. {
  13. DateTime start = DateTime.Now;
  14.  
  15. int width = 800;
  16. int height = 600;
  17.  
  18. Col[,] array = new Col[width, height];
  19.  
  20. WriteInfo("malloc(" + width + ", " + height + ")", start);
  21. start = DateTime.Now;
  22.  
  23. for (int i = 0; i != width; i++)
  24. {
  25. for (int j = 0; j != height; j++)
  26. {
  27. array[i,j] = new Col(1, 2, 3);
  28. }
  29. }
  30.  
  31. WriteInfo("init(" + width + ", " + height + ")", start);
  32.  
  33. Random r = new Random();
  34.  
  35. while (true)
  36. {
  37. start = DateTime.Now;
  38.  
  39. Col* arrayPtr = null;
  40.  
  41. for (int i = 0; i != width; i++)
  42. {
  43. fixed (Col* ptr = &array[i, 0])
  44. {
  45. arrayPtr = ptr;
  46. for (int j = 0; j != height; j++)
  47. {
  48. arrayPtr->a = (arrayPtr->b) * (arrayPtr->c);
  49. arrayPtr->b = (arrayPtr->a) * (arrayPtr->c);
  50. arrayPtr->c = (arrayPtr->a) * (arrayPtr->b);
  51. arrayPtr++;
  52. }
  53. }
  54. }
  55.  
  56. Console.SetCursorPosition(0, 2);
  57. WriteInfo("re-set(" + width + ", " + height + ")", start);
  58. }
  59.  
  60. }
  61.  
  62. static void WriteInfo(string prefix, DateTime start)
  63. {
  64. Console.WriteLine(prefix + ": " + Math.Round((DateTime.Now - start).TotalMilliseconds) + " ms -> " + Math.Round(1000 / (DateTime.Now - start).TotalMilliseconds) + " fps ");
  65. }
  66. }
  67. struct Col
  68. {
  69. public float a;
  70. public float b;
  71. public float c;
  72.  
  73. public Col(float a, float b, float c)
  74. {
  75. this.a = a;
  76. this.b = b;
  77. this.c = c;
  78. }
  79. }
  80. }
  81.