File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Diagnostics ;
3+ using Oxide . Pooling ;
4+
5+ namespace Oxide ;
6+
7+ public class Benchmarker : IDisposable
8+ {
9+ private string _input ;
10+ private Stopwatch _stopwatch ;
11+
12+ public static Benchmarker Start ( string input )
13+ {
14+ Console . WriteLine ( $ "Started benchmarking { input } ") ;
15+
16+ Benchmarker benchmarker = PoolFactory < Benchmarker > . Shared . Take ( ) ;
17+ benchmarker . _input = input ;
18+ benchmarker . _stopwatch = PoolFactory < Stopwatch > . Shared . Take ( ) ;
19+ benchmarker . _stopwatch . Start ( ) ;
20+ return benchmarker ;
21+ }
22+
23+ public void Dispose ( )
24+ {
25+ _stopwatch . Stop ( ) ;
26+
27+ Console . WriteLine ( $ "{ _input } took { _stopwatch . Elapsed } [{ _stopwatch . ElapsedTicks } ticks]") ;
28+
29+ PoolFactory < Stopwatch > . Shared . Return ( _stopwatch ) ;
30+ PoolFactory < Benchmarker > . Shared . Return ( this ) ;
31+
32+ _input = null ;
33+ _stopwatch = null ;
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments