mirror of
https://gitee.com/dotnetchina/MiniExcel.git
synced 2024-12-02 03:47:41 +08:00
fix unit test dotnet yml
This commit is contained in:
parent
689cf5d78e
commit
bb3b1901c2
6
.github/workflows/dotnet.yml
vendored
6
.github/workflows/dotnet.yml
vendored
@ -12,11 +12,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v2
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@v3
|
uses: actions/setup-dotnet@v1
|
||||||
with:
|
with:
|
||||||
dotnet-version: 6.0.x
|
dotnet-version: 5.0.x
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore
|
run: dotnet restore
|
||||||
- name: Build
|
- name: Build
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
Your <a href="https://github.com/shps951023/MiniExcel">Star</a> and <a href="https://miniexcel.github.io">Donate</a> can make MiniExcel better
|
Your <a href="https://github.com/shps951023/MiniExcel">Star</a> and <a href="https://miniexcel.github.io">Donate</a> can make MiniExcel better
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Introduction
|
### Introduction
|
||||||
|
@ -1,84 +0,0 @@
|
|||||||
using CsvHelper;
|
|
||||||
using MiniExcelLibs.Tests.Utils;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace MiniExcelLibs.Tests
|
|
||||||
{
|
|
||||||
public class PerformanceEnhancementTest
|
|
||||||
{
|
|
||||||
[Fact]
|
|
||||||
public void StartsWithPerformanceCompare()
|
|
||||||
{
|
|
||||||
string stringVal = "@@@fileid@@@,tteffadasdas ", findVal = "@@@fileid@@@,";
|
|
||||||
const int LOOP = 5000000;
|
|
||||||
int runTimes = 0;
|
|
||||||
long normalMilliseconds = 0;
|
|
||||||
long ordinalMilliseconds = 0;
|
|
||||||
|
|
||||||
Stopwatch watch = Stopwatch.StartNew();
|
|
||||||
for (int i = 0; i < LOOP; i++)
|
|
||||||
{
|
|
||||||
if (stringVal.StartsWith(findVal))
|
|
||||||
runTimes++;
|
|
||||||
}
|
|
||||||
watch.Stop();
|
|
||||||
normalMilliseconds = watch.ElapsedMilliseconds;
|
|
||||||
Assert.Equal(LOOP, runTimes);
|
|
||||||
|
|
||||||
runTimes = 0;
|
|
||||||
watch = Stopwatch.StartNew();
|
|
||||||
for (int i = 0; i < LOOP; i++)
|
|
||||||
{
|
|
||||||
if (stringVal.StartsWith(findVal,StringComparison.Ordinal))
|
|
||||||
runTimes++;
|
|
||||||
}
|
|
||||||
watch.Stop();
|
|
||||||
ordinalMilliseconds = watch.ElapsedMilliseconds;
|
|
||||||
|
|
||||||
Assert.Equal(LOOP, runTimes);
|
|
||||||
Assert.True(normalMilliseconds > ordinalMilliseconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void EndWithPerformanceCompare()
|
|
||||||
{
|
|
||||||
string stringVal = "@@@fileid@@@,tteffadasdas ", findVal = " ";
|
|
||||||
const int LOOP = 5000000;
|
|
||||||
int runTimes = 0;
|
|
||||||
long normalMilliseconds = 0;
|
|
||||||
long ordinalMilliseconds = 0;
|
|
||||||
|
|
||||||
Stopwatch watch = Stopwatch.StartNew();
|
|
||||||
for (int i = 0; i < LOOP; i++)
|
|
||||||
{
|
|
||||||
if (stringVal.EndsWith(findVal))
|
|
||||||
runTimes++;
|
|
||||||
}
|
|
||||||
watch.Stop();
|
|
||||||
normalMilliseconds = watch.ElapsedMilliseconds;
|
|
||||||
Assert.Equal(LOOP, runTimes);
|
|
||||||
|
|
||||||
runTimes = 0;
|
|
||||||
watch = Stopwatch.StartNew();
|
|
||||||
for (int i = 0; i < LOOP; i++)
|
|
||||||
{
|
|
||||||
if (stringVal.EndsWith(findVal,StringComparison.Ordinal))
|
|
||||||
runTimes++;
|
|
||||||
}
|
|
||||||
watch.Stop();
|
|
||||||
ordinalMilliseconds = watch.ElapsedMilliseconds;
|
|
||||||
|
|
||||||
Assert.Equal(LOOP, runTimes);
|
|
||||||
Assert.True(normalMilliseconds > ordinalMilliseconds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user