Advertisement
POdkovyrkinDaniil

Untitled

Dec 17th, 2017
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4.  
  5. namespace Profiling
  6. {
  7. public class ProfilerTask : IProfiler
  8. {
  9. public List<ExperimentResult> Measure(IRunner runner, int repetitionsCount)
  10. {
  11. var results = new List<ExperimentResult>();
  12. foreach (var size in Constants.FieldCounts)
  13. {
  14. var sutructWorkTime = GetWorkTime(runner, false, size, repetitionsCount);
  15. var classWorkTime = GetWorkTime(runner, true, size, repetitionsCount);
  16. results.Add(new ExperimentResult(size, classWorkTime, sutructWorkTime));
  17. }
  18. return results;
  19. }
  20. private double GetWorkTime(IRunner runner, bool isClass, int size, int count)
  21. {
  22. runner.Call( isClass, size, 1);
  23. var watch = new Stopwatch();
  24. watch.Start();
  25. runner.Call (isClass, size, count);
  26. watch.Stop();
  27. return (double)watch.ElapsedMilliseconds / count;
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement