private static async Task <double> BenchLoadedReusltAsync(int n, string fileName) { Stopwatch stopwatch = new Stopwatch(); var policy = await DataSharingPolicyParser.ParseFromFileAsync(fileName); stopwatch.Start(); for (int i = 0; i < n; i++) { policy.Check("NotPaul"); } stopwatch.Stop(); double result = stopwatch.ElapsedTicks * 1000000 / Stopwatch.Frequency; return(result); }
private async static Task <double> BenchUnLoadedReuslt(int n, string fileName) { Stopwatch stopwatch = new Stopwatch(); Console.WriteLine("Testing file {0} for {1} loops", fileName, n); stopwatch.Start(); for (int i = 0; i < n; i++) { var policy = await DataSharingPolicyParser.ParseFromFileAsync(fileName); policy.Check("NotPaul"); } stopwatch.Stop(); double result = stopwatch.ElapsedTicks * 1000000 / Stopwatch.Frequency; return(result); }
private static DataSharingPolciy LoadFromFile(long id) { var filePath = "polcies\\policy" + id.ToString() + ".json"; return(DataSharingPolicyParser.ParseFromFileAsync(filePath).GetAwaiter().GetResult()); }
public static async Task ExportToFile(long id, DataSharingPolciy polciy) { #pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed DataSharingPolicyParser.ExportToJson(polciy, "polcies\\policy" + id.ToString() + ".json"); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }