Skip to content

Commit 27aac66

Browse files
committed
move performance report build targets and create first reports
1 parent 41fef58 commit 27aac66

12 files changed

Lines changed: 137 additions & 45 deletions

build/Build.fs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ let _preRelease =
2929
"PreRelease"
3030
[setPrereleaseTag; clean; build; runTests; packPrerelease; createPrereleaseTag; publishNugetPrerelease; publishNPMPrerelease]
3131

32-
ReleaseNotesTasks.updateReleaseNotes |> ignore
33-
3432
[<EntryPoint>]
3533
let main args =
3634
runOrDefault build args

build/Build.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<Compile Include="BasicTasks.fs" />
1414
<Compile Include="GenerateIndexJs.fs" />
1515
<Compile Include="GenerateIndexPy.fs" />
16+
<Compile Include="PerformanceTasks.fs" />
1617
<Compile Include="TestTasks.fs" />
1718
<Compile Include="PackageTasks.fs" />
1819
<Compile Include="ReleaseTasks.fs" />

build/PerformanceTasks.fs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module PerformanceTasks
2+
3+
open BlackFox.Fake
4+
open Fake.DotNet
5+
6+
open ProjectInfo
7+
open BasicTasks
8+
open Fake.Core
9+
10+
module PerformanceReport =
11+
12+
let cpu =
13+
Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\SYSTEM\\CentralProcessor\\0", "ProcessorNameString", null) :?> string
14+
15+
let testPerformancePy = BuildTask.create "testPerformancePy" [clean; build] {
16+
let path = "tests/TestingUtils"
17+
//transpile py files from fsharp code
18+
run dotnet $"fable {path} -o {path}/py --lang python" ""
19+
// run pyxpecto in target path to execute tests in python
20+
run python $"{path}/py/performance_report.py \"{cpu}\"" ""
21+
}
22+
let testPerformanceJs = BuildTask.create "testPerformanceJS" [clean; build] {
23+
let path = "tests/TestingUtils"
24+
// transpile js files from fsharp code
25+
run dotnet $"fable {path} -o {path}/js" ""
26+
// run mocha in target path to execute tests
27+
run npx $"mocha {path}/js \"{cpu}\"" ""
28+
}
29+
let testPerformanceDotnet = BuildTask.create "testPerformanceDotnet" [clean; build] {
30+
let path = "tests/TestingUtils"
31+
run dotnet $"run --project {path} \"{cpu}\"" ""
32+
}
33+
34+
let perforanceReport = BuildTask.create "PerformanceReport" [PerformanceReport.testPerformancePy; PerformanceReport.testPerformanceJs; PerformanceReport.testPerformanceDotnet] {
35+
()
36+
}

build/TestTasks.fs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -61,35 +61,6 @@ module RunTests =
6161
|> Seq.iter dotnetRun
6262
}
6363

64-
65-
module PerformanceReport =
66-
67-
let cpu =
68-
Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\SYSTEM\\CentralProcessor\\0", "ProcessorNameString", null) :?> string
69-
70-
let testPerformancePy = BuildTask.create "testPerformancePy" [clean; build] {
71-
let path = "tests/TestingUtils"
72-
//transpile py files from fsharp code
73-
run dotnet $"fable {path} -o {path}/py --lang python" ""
74-
// run pyxpecto in target path to execute tests in python
75-
run python $"{path}/py/performance_report.py {cpu}" ""
76-
}
77-
let testPerformanceJs = BuildTask.create "testPerformanceJS" [clean; build] {
78-
let path = "tests/TestingUtils"
79-
// transpile js files from fsharp code
80-
run dotnet $"fable {path} -o {path}/js" ""
81-
// run mocha in target path to execute tests
82-
run npx $"mocha {path}/js {cpu}" ""
83-
}
84-
let testPerformanceDotnet = BuildTask.create "testPerformanceDotnet" [clean; build] {
85-
let path = "tests/TestingUtils"
86-
run dotnet $"run --project {path} {cpu}" ""
87-
}
88-
89-
let perforanceReport = BuildTask.create "PerformanceReport" [PerformanceReport.testPerformancePy; PerformanceReport.testPerformanceJs; PerformanceReport.testPerformanceDotnet] {
90-
()
91-
}
92-
9364
let runTests = BuildTask.create "RunTests" [clean; build; RunTests.runTestsJs; RunTests.runTestsJsNative; RunTests.runTestsPy; RunTests.runTestsDotnet] {
9465
()
9566
}

docs/scripts_fsharp/ArcInvestigation.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ open FsSpreadsheet.Net
2020

2121
let fswb = ArcInvestigation.toFsWorkbook investigation_comments
2222

23-
fswb.ToFile("test2.isa.investigation.xlsx")
23+
fswb.ToXlsxFile("test2.isa.investigation.xlsx")
2424

2525
// ## Json - Write
2626

tests/TestingUtils/Library.fs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ type Stopwatch() =
5959
| Some start, Some stop -> stop - start
6060
| _, _ -> failwith "Error. Unable to call `Elapsed` without calling `Start` and `Stop` before."
6161

62+
static member measure f =
63+
let stopwatch = Stopwatch()
64+
stopwatch.Start()
65+
let res = f()
66+
stopwatch.Stop()
67+
stopwatch.Elapsed.TotalMilliseconds
68+
6269
/// Fable compatible Expecto/Mocha/Pyxpecto unification
6370
module Expect =
6471
open Utils

tests/TestingUtils/PerformanceReport.fs

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,29 @@
33
open ARCtrl.ISA
44
open ARCtrl.ISA.Json
55
open ARCtrl.ISA.Spreadsheet
6+
open Fable.Core
7+
8+
#if FABLE_COMPILER_JAVASCRIPT
9+
open Node.Api
10+
#endif
11+
12+
#if FABLE_COMPILER_PYTHON
13+
open Fable.Python.Builtins
14+
#endif
15+
16+
let writeFile (path : string) (content : string) =
17+
#if FABLE_COMPILER_JAVASCRIPT
18+
fs.writeFileSync(path,content)
19+
#endif
20+
#if FABLE_COMPILER_PYTHON
21+
let file = builtins.``open``(path, OpenTextMode.Write)
22+
file.write(content) |> ignore
23+
#endif
24+
#if !FABLE_COMPILER
25+
System.IO.File.WriteAllText(path,content)
26+
#endif
27+
28+
//fs.writeFile(path,content)
629

730
type PerformanceTest =
831
{
@@ -13,12 +36,10 @@ type PerformanceTest =
1336
}
1437

1538
member this.Run() =
16-
printfn "Running test: %s" this.Name
17-
let timer_start = System.DateTime.Now
18-
this.Test()
19-
let timer_end = System.DateTime.Now
20-
let runtime = (timer_end - timer_start).Milliseconds
21-
{this with Time = Some runtime}
39+
printfn "%A: Running test: %s" System.DateTime.Now this.Name
40+
let time = TestingUtils.Stopwatch.measure(this.Test) |> int
41+
printfn "\tC%A: Completeted in %ims" System.DateTime.Now time
42+
{this with Time = Some time}
2243

2344
static member create name description test = {Name = name; Description = description; Test = test; Time = None}
2445

@@ -35,7 +56,7 @@ type PerformanceReport =
3556
{this with Tests = this.Tests |> List.map (fun t -> t.Run())}
3657

3758
member this.ToMarkdown() =
38-
let header = $"| Name | Description | CPU | Lang Time (ms) |"
59+
let header = $"| Name | Description | CPU | {this.Lang} Time (ms) |"
3960
let separator = $"| --- | --- | --- | --- |"
4061
let tests = this.Tests |> List.map (fun t -> $"| {t.Name} | {t.Description} | {this.CPU} | {t.Time.Value} |")
4162
String.concat "\n" [header; separator; tests |> String.concat "\n"]
@@ -111,16 +132,15 @@ let table_toJson =
111132
let t = TestObjects.Spreadsheet.Study.LargeFile.table
112133
PerformanceTest.create
113134
"Table_ToJson"
114-
""
135+
"Serialize a table with 5 columns and 10000 rows to json."
115136
(fun _ -> t.ToJsonString() |> ignore)
116137

117138
let table_toCompressedJson =
118139
let t = TestObjects.Spreadsheet.Study.LargeFile.table
119140
PerformanceTest.create
120141
"Table_ToCompressedJson"
121-
""
122-
(fun _ -> t.ToCompressedJsonString() |> ignore)
123-
142+
"Serialize a table with 5 columns and 10000 rows to compressed json."
143+
(fun _ -> t.ToCompressedJsonString() |> ignore)
124144

125145
let assay_toJson =
126146
let a = ArcAssay.init("MyAssay")
@@ -192,13 +212,29 @@ let lang =
192212
"Python"
193213
#endif
194214
#if !FABLE_COMPILER
195-
"F#"
215+
"FSharp"
216+
#endif
217+
218+
219+
let argumentNumber =
220+
#if FABLE_COMPILER_JAVASCRIPT
221+
1
222+
#else
223+
0
196224
#endif
197225

198226

199227
[<EntryPoint>]
200228
let main argv =
201-
let cpu = argv.[1]
229+
printfn "Arguments:"
230+
for arg in argv do
231+
printfn "\t%s" arg
232+
let cpu = argv.[argumentNumber]
202233
let report = createMarkdownPerformanceReport lang cpu
234+
let timeString =
235+
let dt = System.DateTime.Today
236+
$"{dt.Year}_{dt.Month}_{dt.Day}"
237+
let outFile = $"tests/TestingUtils/PerformanceReport/{timeString}_PerformanceReport_{lang}.md"
238+
writeFile outFile report
203239
printfn "%s" report
204240
0
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Measured on 13th Gen Intel(R) Core(TM) i7-13800H
2+
3+
| Name | Description | FSharp Time (ms) | JavaScript Time (ms) | Python Time (ms) |
4+
| --- | --- | --- | --- | --- |
5+
| Table_GetHashCode | From a table with 1 column and 10000 rows, retrieve the Hash Code | 5 | 21 | 226 |
6+
| Table_AddRows | Add 10000 rows to a table with 4 columns. | 15 | 22 | 289 |
7+
| Table_fillMissingCells | For a table 6 columns and 20000 rows, where each row has one missing value, fill those values with default values. | 49 | 108 | 4813 |
8+
| Table_ToJson | Serialize a table with 5 columns and 10000 rows to json. | 1099 | 481 | 6833 |
9+
| Table_ToCompressedJson | Serialize a table with 5 columns and 10000 rows to compressed json. | 261 | 2266 | 717334 |
10+
| Assay_toJson | Parse an assay with one table with 10000 rows and 6 columns to json | 915 | 2459 | 28799 |
11+
| Study_FromWorkbook | Parse a workbook with one study with 10000 rows and 6 columns to an ArcStudy | 97 | 87 | 1249 |
12+
| Investigation_ToWorkbook_ManyStudies | Parse an investigation with 1500 studies to a workbook | 621 | 379 | 9974 |
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
| Name | Description | CPU | FSharp Time (ms) |
2+
| --- | --- | --- | --- |
3+
| Table_GetHashCode | From a table with 1 column and 10000 rows, retrieve the Hash Code | 13th Gen Intel(R) Core(TM) i7-13800H | 5 |
4+
| Table_AddRows | Add 10000 rows to a table with 4 columns. | 13th Gen Intel(R) Core(TM) i7-13800H | 15 |
5+
| Table_fillMissingCells | For a table 6 columns and 20000 rows, where each row has one missing value, fill those values with default values. | 13th Gen Intel(R) Core(TM) i7-13800H | 49 |
6+
| Table_ToJson | Serialize a table with 5 columns and 10000 rows to json. | 13th Gen Intel(R) Core(TM) i7-13800H | 1099 |
7+
| Table_ToCompressedJson | Serialize a table with 5 columns and 10000 rows to compressed json. | 13th Gen Intel(R) Core(TM) i7-13800H | 261 |
8+
| Assay_toJson | Parse an assay with one table with 10000 rows and 6 columns to json | 13th Gen Intel(R) Core(TM) i7-13800H | 915 |
9+
| Study_FromWorkbook | Parse a workbook with one study with 10000 rows and 6 columns to an ArcStudy | 13th Gen Intel(R) Core(TM) i7-13800H | 97 |
10+
| Investigation_ToWorkbook_ManyStudies | Parse an investigation with 1500 studies to a workbook | 13th Gen Intel(R) Core(TM) i7-13800H | 621 |
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
| Name | Description | CPU | JavaScript Time (ms) |
2+
| --- | --- | --- | --- |
3+
| Table_GetHashCode | From a table with 1 column and 10000 rows, retrieve the Hash Code | 13th Gen Intel(R) Core(TM) i7-13800H | 21 |
4+
| Table_AddRows | Add 10000 rows to a table with 4 columns. | 13th Gen Intel(R) Core(TM) i7-13800H | 22 |
5+
| Table_fillMissingCells | For a table 6 columns and 20000 rows, where each row has one missing value, fill those values with default values. | 13th Gen Intel(R) Core(TM) i7-13800H | 108 |
6+
| Table_ToJson | Serialize a table with 5 columns and 10000 rows to json. | 13th Gen Intel(R) Core(TM) i7-13800H | 481 |
7+
| Table_ToCompressedJson | Serialize a table with 5 columns and 10000 rows to compressed json. | 13th Gen Intel(R) Core(TM) i7-13800H | 2266 |
8+
| Assay_toJson | Parse an assay with one table with 10000 rows and 6 columns to json | 13th Gen Intel(R) Core(TM) i7-13800H | 2459 |
9+
| Study_FromWorkbook | Parse a workbook with one study with 10000 rows and 6 columns to an ArcStudy | 13th Gen Intel(R) Core(TM) i7-13800H | 87 |
10+
| Investigation_ToWorkbook_ManyStudies | Parse an investigation with 1500 studies to a workbook | 13th Gen Intel(R) Core(TM) i7-13800H | 379 |

0 commit comments

Comments
 (0)