Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- namespace Profiling
- {
- public class ProfilerTask : IProfiler
- {
- public List<ExperimentResult> Measure(IRunner runner, int repetitionsCount)
- {
- var results = new List<ExperimentResult>();
- foreach (var size in Constants.FieldCounts)
- {
- var sutructWorkTime = GetWorkTime(runner, false, size, repetitionsCount);
- var classWorkTime = GetWorkTime(runner, true, size, repetitionsCount);
- results.Add(new ExperimentResult(size, classWorkTime, sutructWorkTime));
- }
- return results;
- }
- private double GetWorkTime(IRunner runner, bool isClass, int size, int count)
- {
- runner.Call( isClass, size, 1);
- var watch = new Stopwatch();
- watch.Start();
- runner.Call (isClass, size, count);
- watch.Stop();
- return (double)watch.ElapsedMilliseconds / count;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement