~ubuntu-branches/ubuntu/trusty/smuxi/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/ServiceStack/src/ServiceStack.Common/Utils/PerfUtils.cs

  • Committer: Package Import Robot
  • Author(s): Mirco Bauer
  • Date: 2013-05-25 22:11:31 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20130525221131-nd2mc0kzubuwyx20
Tags: 0.8.11-1
* [22d13d5] Imported Upstream version 0.8.11
* [6d2b95a] Refreshed patches
* [89eb66e] Added ServiceStack libraries to smuxi-engine package
* [848ab10] Enable Campfire engine
* [c6dbdc7] Always build db4o for predictable build result
* [13ec489] Exclude OS X specific libraries from dh_clideps

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#if !SILVERLIGHT && !MONOTOUCH && !XBOX
 
2
 
 
3
using System;
 
4
using System.Diagnostics;
 
5
 
 
6
namespace ServiceStack.Common.Utils
 
7
{
 
8
    public static class PerfUtils
 
9
    {
 
10
        public static TimeSpan ToTimeSpan(this long fromTicks)
 
11
        {
 
12
            return TimeSpan.FromSeconds(fromTicks * 1d / Stopwatch.Frequency);
 
13
        }
 
14
 
 
15
        public static long Measure(long iterations, Action action)
 
16
        {
 
17
            GC.Collect();
 
18
            var begin = Stopwatch.GetTimestamp();
 
19
 
 
20
            for (var i = 0; i < iterations; i++)
 
21
            {
 
22
                action();
 
23
            }
 
24
 
 
25
            var end = Stopwatch.GetTimestamp();
 
26
 
 
27
            return (end - begin);
 
28
        }
 
29
    }
 
30
}
 
31
 
 
32
#endif
 
 
b'\\ No newline at end of file'