forked from microsoft/Quantum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtensions.cs
40 lines (38 loc) · 1.05 KB
/
Extensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Microsoft.Quantum.Simulation.Simulators.QCTraceSimulators;
namespace Microsoft.Quantum.Chemistry.Samples
{
public static class Extensions
{
public static void WriteResultsToFolder(
this QCTraceSimulator sim,
string outputFolder,
string baseName
)
{
var gateStats = sim.ToCSV();
foreach (var x in gateStats)
{
System.IO.File.WriteAllLines(
System.IO.Path.Join(
outputFolder,
$"{baseName}.{x.Key}.csv"
), new string[] { x.Value }
);
}
}
public async static Task<T> Measure<T>(
this Stopwatch stopwatch,
Func<Task<T>> action
)
{
stopwatch.Reset();
stopwatch.Start();
var result = await action();
stopwatch.Stop();
return result;
}
}
}