FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
oxyplot/Source/Examples/PerformanceTest/Program.cs at develop · CodingConnected/oxyplot · GitHub
CodingConnected
oxyplot
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
oxyplot
/
Source
/
Examples
/
PerformanceTest
/
Program.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
148 lines (131 loc) · 4.88 KB
Breadcrumbs
oxyplot
/
Source
/
Examples
/
PerformanceTest
/
Program.cs
Copy path
File metadata and controls
148 lines (131 loc) · 4.88 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Program.cs" company="OxyPlot">
// Copyright (c) 2014 OxyPlot contributors
// </copyright>
// <summary>
// A performance test program.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace
PerformanceTest
{
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Diagnostics
;
using
OxyPlot
;
using
OxyPlot
.
Series
;
/// <summary>
/// A performance test program.
/// </summary>
/// <remarks>
/// Build with the Release configuration.
/// To be used with a profiler or as a standalone program (remember to run outside the Visual Studio IDE).
/// </remarks>
public
class
Program
{
/// <summary>
/// The program entry point.
/// </summary>
public
static
void
Main
(
)
{
var
testModels
=
new
Dictionary
<
string
,
PlotModel
>
{
{
"LineSeries with 100000 points"
,
CreateModel
(
100000
)
}
,
{
"LineSeries with 100000 points in ItemsSource"
,
CreateModel2
(
100000
)
}
}
;
foreach
(
var
kvp
in
testModels
)
{
Console
.
WriteLine
(
kvp
.
Key
)
;
TestModelUpdate
(
kvp
.
Value
)
;
TestModelRender
(
kvp
.
Value
)
;
Console
.
WriteLine
(
)
;
}
Console
.
WriteLine
(
"DrawReducedLine test:"
)
;
var
t0
=
TestDrawReducedLine
(
10000
,
1000
,
false
)
;
var
t1
=
TestDrawReducedLine
(
10000
,
1000
,
true
)
;
Console
.
WriteLine
(
"{0:P1}"
,
(
t0
-
t1
)
/
t0
)
;
Console
.
ReadKey
(
)
;
}
public
static
double
TestModelUpdate
(
PlotModel
model
,
int
m
=
1000
)
{
var
stopwatch
=
Stopwatch
.
StartNew
(
)
;
for
(
int
i
=
0
;
i
<
m
;
i
++
)
{
(
(
IPlotModel
)
model
)
.
Update
(
true
)
;
}
stopwatch
.
Stop
(
)
;
Console
.
WriteLine
(
"Update: {0}"
,
(
double
)
stopwatch
.
ElapsedMilliseconds
)
;
return
stopwatch
.
ElapsedMilliseconds
;
}
public
static
double
TestModelRender
(
PlotModel
model
,
int
m
=
100
)
{
var
rc
=
new
EmptyRenderContext
(
)
;
var
stopwatch
=
Stopwatch
.
StartNew
(
)
;
for
(
int
i
=
0
;
i
<
m
;
i
++
)
{
(
(
IPlotModel
)
model
)
.
Render
(
rc
,
new
OxyRect
(
0
,
0
,
800
,
600
)
)
;
}
stopwatch
.
Stop
(
)
;
Console
.
WriteLine
(
"Render: {0}"
,
(
double
)
stopwatch
.
ElapsedMilliseconds
)
;
return
stopwatch
.
ElapsedMilliseconds
;
}
private
static
PlotModel
CreateModel
(
int
n
)
{
var
model
=
new
PlotModel
(
)
;
var
series
=
new
LineSeries
(
)
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
series
.
Points
.
Add
(
new
DataPoint
(
i
,
Math
.
Sin
(
i
)
)
)
;
}
model
.
Series
.
Add
(
series
)
;
(
(
IPlotModel
)
model
)
.
Update
(
true
)
;
return
model
;
}
private
static
PlotModel
CreateModel2
(
int
n
)
{
var
points
=
new
List
<
DataPoint
>
(
)
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
points
.
Add
(
new
DataPoint
(
i
,
Math
.
Sin
(
i
)
)
)
;
}
var
model
=
new
PlotModel
(
)
;
var
series
=
new
LineSeries
(
)
;
series
.
ItemsSource
=
points
;
model
.
Series
.
Add
(
series
)
;
(
(
IPlotModel
)
model
)
.
Update
(
true
)
;
return
model
;
}
/// <summary>
/// Tests the <see cref="RenderingExtensions.DrawReducedLine" /> method.
/// </summary>
/// <param name="n">The number of points.</param>
/// <param name="m">The number of repetitions.</param>
/// <param name="useOutputBuffer"><c>true</c> to use an output buffer.</param>
/// <returns>The elapsed time in milliseconds.</returns>
public
static
double
TestDrawReducedLine
(
int
n
,
int
m
,
bool
useOutputBuffer
)
{
var
points
=
new
ScreenPoint
[
n
]
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
points
[
i
]
=
new
ScreenPoint
(
(
double
)
i
/
n
,
Math
.
Sin
(
40d
*
i
/
n
)
)
;
}
var
rc
=
new
EmptyRenderContext
(
)
;
var
outputBuffer
=
useOutputBuffer
?
new
List
<
ScreenPoint
>
(
n
)
:
null
;
var
stopwatch
=
Stopwatch
.
StartNew
(
)
;
for
(
int
i
=
0
;
i
<
m
;
i
++
)
{
rc
.
DrawReducedLine
(
points
,
1
,
OxyColors
.
Black
,
1
,
EdgeRenderingMode
.
Automatic
,
null
,
LineJoin
.
Miter
,
outputBuffer
)
;
}
stopwatch
.
Stop
(
)
;
Console
.
WriteLine
(
(
double
)
stopwatch
.
ElapsedMilliseconds
)
;
return
stopwatch
.
ElapsedMilliseconds
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL