Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.2 KiB

  1. //+------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993.
  5. //
  6. // File: bm_noise.cxx
  7. //
  8. // Contents: output class for benchmark results
  9. //
  10. // Classes: CNoiseTest
  11. //
  12. // History: 30-June-93 t-martig Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #include <headers.cxx>
  16. #pragma hdrstop
  17. #include <bm_noise.hxx>
  18. TCHAR *CNoiseTest::Name ()
  19. {
  20. return TEXT("Noise Test");
  21. }
  22. SCODE CNoiseTest::Setup (CTestInput *pInput)
  23. {
  24. CTestBase::Setup(pInput);
  25. // get iteration count
  26. m_ulIterations = pInput->GetIterations(Name(), TEST_MAX_ITERATIONS);
  27. INIT_RESULTS(m_ulNoiseTime);
  28. return S_OK;
  29. }
  30. SCODE CNoiseTest::Run ()
  31. {
  32. CStopWatch sw;
  33. int n;
  34. FILE *pfDump;
  35. char buffer[100];
  36. int i;
  37. m_ulResolution = sw.Resolution();
  38. sw.Reset();
  39. Sleep (1000);
  40. m_ulSleep = sw.Read();
  41. sw.Reset();
  42. for (n=0; n<10000; n++);
  43. m_ulIdle = sw.Read();
  44. for (ULONG iIter=0; iIter<m_ulIterations; iIter++)
  45. {
  46. sw.Reset();
  47. m_ulNoiseTime[iIter] = sw.Read();
  48. }
  49. pfDump = fopen ("C:\\DUMP.BM", "wb");
  50. if (pfDump)
  51. {
  52. sw.Reset();
  53. for (i=0; i<1000; i++)
  54. fwrite (&buffer, 1, 100, pfDump);
  55. m_ulDumpWrite = sw.Read();
  56. fclose (pfDump);
  57. pfDump = fopen ("C:\\DUMP.BM", "rb");
  58. if (pfDump)
  59. {
  60. sw.Reset();
  61. for (i=0; i<1000; i++)
  62. fread (&buffer, 1, 100, pfDump);
  63. m_ulDumpRead = sw.Read();
  64. fclose (pfDump);
  65. }
  66. else
  67. m_ulDumpRead = 0xffffffff;
  68. _unlink ("C:\\DUMP.BM");
  69. }
  70. else
  71. m_ulDumpWrite = 0xffffffff;
  72. return S_OK;
  73. }
  74. SCODE CNoiseTest::Report (CTestOutput &output)
  75. {
  76. output.WriteSectionHeader (Name(), NULL, *m_pInput);
  77. output.WriteResult (TEXT("Resolution"), m_ulResolution);
  78. output.WriteResult (TEXT("Sleep 1000ms"), m_ulSleep);
  79. output.WriteResult (TEXT("Idle 10000 loops"), m_ulIdle);
  80. output.WriteResults (TEXT("Noise"), m_ulIterations, m_ulNoiseTime);
  81. output.WriteResult (TEXT("Write 100k to disk"), m_ulDumpWrite);
  82. output.WriteResult (TEXT("Read 100k from disk"), m_ulDumpRead);
  83. return S_OK;
  84. }
  85.