Skip to content

Commit 294e556

Browse files
feat: add simple performance indicators
1 parent d37cded commit 294e556

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

  • ClassicMachineLearning/PredictIfHouseIsExpensive
  • QuantumMachineLearning/PredictIfHouseIsExpensive/Host

ClassicMachineLearning/PredictIfHouseIsExpensive/Program.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
using System;
2+
using System.Diagnostics;
23
using Microsoft.ML;
34
using Microsoft.ML.Data;
45

6+
var sw = new Stopwatch();
7+
sw.Start();
8+
59
MLContext mlContext = new MLContext();
610

711
HouseData[] houseData =
@@ -40,10 +44,13 @@
4044
.CreatePredictionEngine<HouseData, Prediction>(model)
4145
.Predict(validationData);
4246

47+
sw.Stop();
48+
4349
var size = (validationData.Size * 1000) / 10.76;
4450
var price = (validationData.Price * 100_000) * 5;
4551

4652
Console.WriteLine($"Predicted price for size: {size:F2}m2 and price: {price:C2}. Is expensive? {result.IsExpensive}");
53+
Console.WriteLine("Elapsed={0}", sw.Elapsed);
4754

4855
public class HouseData
4956
{

QuantumMachineLearning/PredictIfHouseIsExpensive/Host/Program.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
using Microsoft.Quantum.Simulation.Simulators;
33
using PredictIfHouseIsExpensive;
44
using PredictIfHouseIsExpensive.Quantum;
5+
using System.Diagnostics;
56
using System.Linq;
67

8+
var sw = new Stopwatch();
9+
sw.Start();
10+
711
HouseData[] houseData =
812
{
913
new HouseData() { Size = 1.1F, Price = 1.2F, IsExpensive = false },
@@ -80,11 +84,15 @@
8084
numberOfMeasurements: numberOfMeasurements
8185
);
8286

87+
sw.Stop();
88+
8389
foreach (var result in results)
8490
{
8591
Console.WriteLine($"Result: {result:F5}.");
8692
}
8793

94+
Console.WriteLine("Elapsed={0}", sw.Elapsed);
95+
8896
public class HouseData
8997
{
9098
public bool IsExpensive { get; set; }

0 commit comments

Comments
 (0)