Skip to content

Commit

Permalink
include parse speed test in js
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Jan 24, 2024
1 parent 9aa368f commit 4732d22
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
<PackageReference Include="Expecto" Version="[10.1.0]" />
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="[0.14.1]" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.*" />
<EmbeddedResource Include="TestFiles/BigFile.xlsx" >
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 15 additions & 0 deletions tests/FsSpreadsheet.Exceljs.Tests/Workbook.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,24 @@ let tests_xlsx = testList "xlsx" [
]
]

let performance =
testList "Performace" [
testCaseAsync "ReadBigFile" <| async {
let sw = Stopwatch()
let p = DefaultTestObject.BigFile.asRelativePathNode
sw.Start()
let! wb = FsWorkbook.fromXlsxFile(p) |> Async.AwaitPromise
sw.Stop()
let ms = sw.Elapsed.Milliseconds
Expect.isTrue (ms < 2000) $"Elapsed time should be less than 2000ms but was {ms}ms"
Expect.equal (wb.GetWorksheetAt(1).Rows.Count) 153991 "Row count should be 153991"
}
]

let main = testList "JsWorkbook<->FsWorkbook" [
tests_toFsWorkbook
tests_toJsWorkbook
tests_xlsx
performance
]

2 changes: 2 additions & 0 deletions tests/TestUtils/DefaultTestObjects.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type TestFiles =
| ClosedXML
| FsSpreadsheetNET
| FsSpreadsheetJS
| BigFile

member this.asFileName =
match this with
Expand All @@ -27,6 +28,7 @@ type TestFiles =
| ClosedXML -> "TestWorkbook_ClosedXML.xlsx"
| FsSpreadsheetNET -> "TestWorkbook_FsSpreadsheet.net.xlsx"
| FsSpreadsheetJS -> "TestWorkbook_FsSpreadsheet.js.xlsx"
| BigFile -> "BigFile.xlsx"

member this.asRelativePath = $"../TestUtils/{testFolder}/{this.asFileName}"
member this.asRelativePathNode = $"./tests/TestUtils/{testFolder}/{this.asFileName}"
Expand Down
File renamed without changes.
Binary file not shown.
39 changes: 21 additions & 18 deletions tests/TestUtils/TestUtils.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="TestFiles\TestWorkbook_ClosedXML.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="TestFiles\TestWorkbook_Excel.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="TestFiles\TestWorkbook_FableExceljs.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="TestFiles\TestWorkbook_Libre.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="TestFiles\TestWorkbook_FsSpreadsheet.net.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="TestFiles\TestWorkbook_FsSpreadsheet.js.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="TestFiles\TestWorkbook_ClosedXML.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="TestFiles\TestWorkbook_Excel.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="TestFiles\TestWorkbook_FableExceljs.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="TestFiles\TestWorkbook_Libre.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="TestFiles\TestWorkbook_FsSpreadsheet.net.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="TestFiles\TestWorkbook_FsSpreadsheet.js.xlsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="TestFiles\BigFile.xlsx" >
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<Compile Include="DefaultTestObjects.fs" />
<Compile Include="TestingUtils.fs" />
</ItemGroup>
Expand Down

0 comments on commit 4732d22

Please sign in to comment.