void RunBenchmark() { // Create a number of levels for us to play with: int maxLevel = 1000; for( int i = 3; i < maxLevel; ++i ) { CreateLevel( i ); } // Run a specified number of tests // to retrieve all levels in different // ways: int nLevels = GetElementsOfType( typeof( Level ) ) .ToElements().Count; int nRuns = 1000; JtTimer totalTimer = new JtTimer( "TOTAL TIME" ); using( totalTimer ) { for( int i = 0; i < nRuns; ++i ) { BenchmarkAllLevels( nLevels ); } } totalTimer.Report( "Retrieve all levels:" ); // Run a specified number of tests // to retrieve a randomly selected // specific level: nRuns = 1000; Random rand = new Random(); totalTimer.Restart( "TOTAL TIME" ); using( totalTimer ) { for( int i = 0; i < nRuns; ++i ) { int iLevel = rand.Next( 1, maxLevel ); BenchmarkSpecificLevel( iLevel ); } } totalTimer.Report( "Retrieve specific named level:" ); }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; _doc = app.ActiveUIDocument.Document; // create a number of levels for us to play with: int maxLevel = 1000; for( int i = 3; i < maxLevel; ++i ) { CreateLevel( i ); } // run a specified number of tests // to retrieve all levels in different // ways: int nLevels = GetElementsOfType( typeof( Level ) ) .ToElements().Count; int nRuns = 1000; JtTimer totalTimer = new JtTimer( "TOTAL TIME" ); using( totalTimer ) { for( int i = 0; i < nRuns; ++i ) { BenchmarkAllLevels( nLevels ); } } totalTimer.Report( "Retrieve all levels:" ); // run a specified number of tests // to retrieve a randomly selected // specific level: nRuns = 1000; Random rand = new Random(); totalTimer.Restart( "TOTAL TIME" ); using( totalTimer ) { for( int i = 0; i < nRuns; ++i ) { int iLevel = rand.Next( 1, maxLevel ); BenchmarkSpecificLevel( iLevel ); } } totalTimer.Report( "Retrieve specific named level:" ); return Result.Failed; }