Ejemplo n.º 1
0
        public override string ToString()
        {
            var writer = new StringWriter();

            _hdrHistogram.OutputPercentileDistribution(writer);
            return(writer.ToString());
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            List <Thread> threadList = new List <Thread>();

            for (int i = 0; i < threadCount; i++)
            {
                Thread t = new Thread(WorkerJob);
                t.Start();
                threadList.Add(t);
            }

            foreach (Thread t in threadList)
            {
                t.Join();
            }

            Console.WriteLine("Total operations: " + throughput);
            double[] percentiles = new double[] { 50, 90, 95, 99, 99.9, 99.99, 100 };
            foreach (double percentile in percentiles)
            {
                Console.WriteLine($"{percentile} : {histogram.GetValueAtPercentile(percentile)}");
            }

            Console.WriteLine("Results:");

            // Write the results to console
            histogram.OutputPercentileDistribution(
                Console.Out,
                percentileTicksPerHalfDistance: 3,
                outputValueUnitScalingRatio: OutputScalingFactor.TimeStampToMilliseconds);

            // Save the results to a file
            using (StreamWriter writer = new StreamWriter("HistogramResults.hgrm"))
            {
                histogram.OutputPercentileDistribution(
                    writer,
                    percentileTicksPerHalfDistance: 3,
                    outputValueUnitScalingRatio: OutputScalingFactor.TimeStampToMilliseconds);
            }

            Console.WriteLine();
            Console.WriteLine("These results have been saved to HistogramResults.hgrm");
        }
Ejemplo n.º 3
0
        private static void WriteResults(RunInfo run, HistogramBase histogram)
        {
            var writer = new StringWriter();

            histogram.OutputPercentileDistribution(writer, outputValueUnitScalingRatio: OutputScalingFactor.TimeStampToMilliseconds);
            Write("hgrm", "text/plain", writer.ToString());
            Write("json", "application/json", JsonConvert.SerializeObject(run, Formatting.Indented));

            void Write(string extension, string contentType, string text)
            {
                string filename = $"run-{run.Id}.{extension}";

                if (run.Configuration.StorageBucket != null)
                {
                    var stream = new MemoryStream(Encoding.UTF8.GetBytes(text));
                    var client = StorageClient.Create();
                    client.UploadObject(run.Configuration.StorageBucket, filename, contentType, stream);
                }
                File.WriteAllText(filename, text);
            }
        }