Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
72 lines (60 loc) · 1.98 KB
/
Copy pathProgram.cs
File metadata and controls
72 lines (60 loc) · 1.98 KB
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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
namespace CreateBitmapStall
{
class Program
{
class DataNode
{
public string Name;
public List<DataNode> SubNodes;
}
static DataNode CreateDataTree(int level, int count, int maxDepth)
{
var subNodes = new List<DataNode>(count);
// resursively generated nodes until maxDepth is reached
if (level < maxDepth)
for (int i = 0; i < count; i++)
subNodes.Add(CreateDataTree(level + 1, count, maxDepth));
return new DataNode()
{
Name = new string('*', 5),
SubNodes = subNodes
};
}
static void CreateBitmapSources()
{
const int size = 64;
for (int i = 0; i < 100; i++)
{
var sw = new Stopwatch();
sw.Start();
var bitData = new byte[size * size * 4];
var bmp = BitmapSource.Create(size, size, 96, 96,
System.Windows.Media.PixelFormats.Bgra32, null, bitData, size * 4);
Console.WriteLine("CreateBitmapSource: {0}ms", sw.ElapsedMilliseconds);
}
}
[STAThread]
static void Main(string[] args)
{
// show file dialog, necessary to cause stalls
var fdlg = new Microsoft.Win32.OpenFileDialog();
fdlg.ShowDialog();
var appData = new HashSet<object>();
// create lots of data and bitmap sources
while (true)
{
Console.WriteLine("creating data...");
appData.Add(CreateDataTree(0, 2, 21));
// create bitmap sources
CreateBitmapSources();
}
}
}
}