You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

This does not seem to be a good way to fix tests:

Also when writing Performance tests - make sure to time the right thing. For example measuring log.Write may give very varying time durations, measure as little block as possible, so instead of:

            ...
            DateTime startTime = DateTime.Now;
            regularGridCoverage.Resize(10000, 10000, 1, 1);
            log.DebugFormat("Writing 100000000 values took {0} ms", (DateTime.Now - startTime).TotalMilliseconds);
            Assert.Less((DateTime.Now - startTime).TotalMilliseconds, 25000);
            ...

Write:

            ...
            var startTime = DateTime.Now;
            regularGridCoverage.Resize(10000, 10000, 1, 1);
            var duration = (DateTime.Now - startTime).TotalMilliseconds;

            log.DebugFormat("Writing 100000000 values took {0} ms", duration);
            Assert.Less(duration, 25000);
            ...

Or:

            ...

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            regularGridCoverage.Resize(10000, 10000, 1, 1);
            stopwatch.Stop();

            log.DebugFormat("Writing 100000000 values took {0} ms", stopwatch.Elapsed.TotalMilliseconds);
            Assert.Less(stopwatch.Elapsed.TotalMilliseconds, 25000);
            ...

Also make sure that message is written showing how log it took to do something, otherwise it is hard to check how long it takes on build server.

  • No labels