Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9fb8436

Browse files
authored
Merge pull request #1051 from losttech/PR/AppVeyorTimings
Report AppVeyor build timings. Lower number of iterations in perf tests to ensure they don't stall AppVeyor.
2 parents f5548e3 + c4bbc8c commit 9fb8436

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

ci/appveyor_build_recipe.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Build `conda.recipe` only if this is a Pull_Request. Saves time for CI.
22

3+
$stopwatch = [Diagnostics.Stopwatch]::StartNew()
4+
35
$env:CONDA_PY = "$env:PY_VER"
46
# Use pre-installed miniconda. Note that location differs if 64bit
57
$env:CONDA_BLD = "C:\miniconda36"
@@ -30,7 +32,9 @@ if ($env:APPVEYOR_PULL_REQUEST_NUMBER -or $env:APPVEYOR_REPO_TAG_NAME -or $env:F
3032

3133
$CONDA_PKG=(conda build conda.recipe --output)
3234
Copy-Item $CONDA_PKG .\dist\
33-
Write-Host "Completed conda build recipe" -ForegroundColor "Green"
35+
36+
$timeSpent = $stopwatch.Elapsed
37+
Write-Host "Completed conda build recipe in " $timeSpent -ForegroundColor "Green"
3438

3539
# Restore PATH back to original
3640
$env:path = $old_path

ci/appveyor_run_tests.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Script to simplify AppVeyor configuration and resolve path to tools
22

3+
$stopwatch = [Diagnostics.Stopwatch]::StartNew()
4+
[array]$timings = @()
5+
36
# Test Runner framework being used for embedded tests
47
$CS_RUNNER = "nunit3-console"
58

@@ -25,6 +28,17 @@ $PY = Get-Command python
2528
$CS_TESTS = ".\src\embed_tests\bin\Python.EmbeddingTest.dll"
2629
$RUNTIME_DIR = ".\src\runtime\bin\"
2730

31+
function ReportTime {
32+
param([string] $action)
33+
34+
$timeSpent = $stopwatch.Elapsed
35+
$timings += [pscustomobject]@{action=$action; timeSpent=$timeSpent}
36+
Write-Host $action " in " $timeSpent -ForegroundColor "Green"
37+
$stopwatch.Restart()
38+
}
39+
40+
ReportTime "Preparation done"
41+
2842
# Run python tests with C# coverage
2943
Write-Host ("Starting Python tests") -ForegroundColor "Green"
3044
.$OPENCOVER -register:user -searchdirs:"$RUNTIME_DIR" -output:py.coverage `
@@ -33,6 +47,9 @@ Write-Host ("Starting Python tests") -ForegroundColor "Green"
3347
$PYTHON_STATUS = $LastExitCode
3448
if ($PYTHON_STATUS -ne 0) {
3549
Write-Host "Python tests failed, continuing to embedded tests" -ForegroundColor "Red"
50+
ReportTime ""
51+
} else {
52+
ReportTime "Python tests completed"
3653
}
3754

3855
# Run Embedded tests with C# coverage
@@ -44,7 +61,10 @@ Write-Host ("Starting embedded tests") -ForegroundColor "Green"
4461
$CS_STATUS = $LastExitCode
4562
if ($CS_STATUS -ne 0) {
4663
Write-Host "Embedded tests failed" -ForegroundColor "Red"
64+
ReportTime ""
4765
} else {
66+
ReportTime "Embedded tests completed"
67+
4868
# NuGet for pythonnet-2.3 only has 64-bit binary for Python 3.5
4969
# the test is only built using modern stack
5070
if (($env:PLATFORM -eq "x64") -and ($XPLAT) -and ($env:PYTHON_VERSION -eq "3.5")) {
@@ -60,6 +80,9 @@ if ($CS_STATUS -ne 0) {
6080
$CS_PERF_STATUS = $LastExitCode
6181
if ($CS_PERF_STATUS -ne 0) {
6282
Write-Host "Performance tests (C#) failed" -ForegroundColor "Red"
83+
ReportTime ""
84+
} else {
85+
ReportTime "Performance tests (C#) completed"
6386
}
6487
} else {
6588
Write-Host ("Skipping performance tests for ", $env:PYTHON_VERSION) -ForegroundColor "Yellow"
@@ -82,9 +105,14 @@ if ($XPLAT){
82105
$CS_STATUS = $LastExitCode
83106
if ($CS_STATUS -ne 0) {
84107
Write-Host "Embedded tests for netcoreapp2.0 failed" -ForegroundColor "Red"
108+
ReportTime ""
109+
} else {
110+
ReportTime ".NET Core 2.0 tests completed"
85111
}
86112
}
87113

114+
Write-Host "Timings:" ($timings | Format-Table | Out-String) -ForegroundColor "Green"
115+
88116
# Set exit code to fail if either Python or Embedded tests failed
89117
if ($PYTHON_STATUS -ne 0 -or $CS_STATUS -ne 0 -or $CS_PERF_STATUS -ne 0) {
90118
Write-Host "Tests failed" -ForegroundColor "Red"

src/perf_tests/PythonCallingNetBenchmark.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void ReadInt64Property()
1919
locals.SetItem("a", new NetObject().ToPython());
2020
PythonEngine.Exec($@"
2121
s = 0
22-
for i in range(300000):
22+
for i in range(50000):
2323
s += a.{nameof(NetObject.LongProperty)}
2424
", locals: locals.Handle);
2525
}
@@ -32,7 +32,7 @@ public void WriteInt64Property() {
3232
locals.SetItem("a", new NetObject().ToPython());
3333
PythonEngine.Exec($@"
3434
s = 0
35-
for i in range(300000):
35+
for i in range(50000):
3636
a.{nameof(NetObject.LongProperty)} += i
3737
", locals: locals.Handle);
3838
}

0 commit comments

Comments
 (0)