Exemplo n.º 1
0
        public override void report(BenchmarkRecord record)
        {
            try
            {
                Directory.CreateDirectory(directory);

                if (!file_initialized)
                {
                    using (var writer = new StreamWriter(filepath))
                        using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
                        {
                            csv.Configuration.RegisterClassMap <CSVBenchmarkReportMap>();
                            csv.WriteHeader <BenchmarkRecord>();
                        }
                    file_initialized = true;
                }

                using (var writer = new StreamWriter(filepath, append: true))
                    using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
                    {
                        csv.Configuration.RegisterClassMap <CSVBenchmarkReportMap>();
                        csv.NextRecord();
                        csv.WriteRecord(record);
                    }
            }
            catch (IOException ioEx)
            {
                HandleIOException(ioEx);
            }
        }
Exemplo n.º 2
0
        public void tick(long elapsedMilliseconds)
        {
            // make sure the first benchmark record is not created immediately but after the reportInterval
            if (lastBenchmarkReport == 0)
            {
                lastBenchmarkReport = elapsedMilliseconds;
                return;
            }

            if (elapsedMilliseconds - lastBenchmarkReport > reportIntervalInMilliseconds)
            {
                var outputRecord = currentRecord;
                currentRecord = new BenchmarkRecord();

                lastBenchmarkReport = elapsedMilliseconds;

                foreach (var reporter in reporters)
                {
                    reporter.report(outputRecord);
                }
            }
        }
Exemplo n.º 3
0
 public abstract void report(BenchmarkRecord record);