Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Program.cs « Benchmarks - github.com/ClusterM/NesTiler.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b90e57adbd2f9c9e7e243e2508ebeaa33ebbd401 (plain)
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

namespace com.clusterrr.Famicom.NesTiler.Benchmarks
{
    public class Benchmarks
    {
        const string ImagesPath = "Images";

        static void Main()
        {
            var summary = BenchmarkRunner.Run<Benchmarks>();
            Console.WriteLine(summary);
        }

        [Benchmark]
        public void BenchmarkBelayaAkula()
        {
            var imagePath = Path.Combine(ImagesPath, "belaya_akula.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkBuhanka()
        {
            var imagePath = Path.Combine(ImagesPath, "buhanka.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkChernobyl()
        {
            var imagePath = Path.Combine(ImagesPath, "chernobyl.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkDira()
        {
            var imagePath = Path.Combine(ImagesPath, "dira.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkGlaza()
        {
            var imagePath = Path.Combine(ImagesPath, "glaza.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkGorgona()
        {
            var imagePath = Path.Combine(ImagesPath, "gorgona.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkMyatejl()
        {
            var imagePath = Path.Combine(ImagesPath, "myatej.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkPagoda()
        {
            var imagePath = Path.Combine(ImagesPath, "pagoda.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkRayon4()
        {
            var imagePath = Path.Combine(ImagesPath, "rayon4.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkShkola()
        {
            var imagePath = Path.Combine(ImagesPath, "shkola.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkSindikat()
        {
            var imagePath = Path.Combine(ImagesPath, "sindikat.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkSputnik()
        {
            var imagePath = Path.Combine(ImagesPath, "sputnik.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkSworm()
        {
            var imagePath = Path.Combine(ImagesPath, "sworm.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkTrailerPark()
        {
            var imagePath = Path.Combine(ImagesPath, "trailer-park.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkWarfaceLogo()
        {
            var imagePath = Path.Combine(ImagesPath, "warface_logo.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkZapravka()
        {
            var imagePath = Path.Combine(ImagesPath, "zapravka.gif");
            DoBenchmarkSplit4(imagePath);
        }

        [Benchmark]
        public void BenchmarkJurassic()
        {
            var imagePath = Path.Combine(ImagesPath, "jurassic.png");
            DoBenchmarkSplit2(imagePath);
        }

        [Benchmark]
        public void BenchmarkJurassic2()
        {
            var imagePath = Path.Combine(ImagesPath, "jurassic2.png");
            DoBenchmarkSplit2(imagePath);
        }

        [Benchmark]
        public void BenchmarkBlasterMasterLeft()
        {
            var imagePath = Path.Combine(ImagesPath, "blaster_master_left.png");
            DoBenchmarkNoSplit(imagePath, "#000000");
        }

        [Benchmark]
        public void BenchmarkBlasterMasterRight()
        {
            var imagePath = Path.Combine(ImagesPath, "blaster_master_right.png");
            DoBenchmarkNoSplit(imagePath, "#000000");
        }

        [Benchmark]
        public void BenchmarkBlasterMasterRightFull()
        {
            var imagePath = Path.Combine(ImagesPath, "blaster_master_right_full.png");
            DoBenchmarkNoSplit(imagePath, "#000000");
        }

        private string PatternTablePath(string prefix, int number) => $"{prefix}_pattern_{number}.bin";
        private string NameTablePath(string prefix, int number) => $"{prefix}_name_table_{number}.bin";
        private string AttrTablePath(string prefix, int number) => $"{prefix}_attr_table_{number}.bin";
        private string PalettePath(string prefix, int number) => $"{prefix}_palette_{number}.bin";

        public void DoBenchmarkNoSplit(string imagePath, string bgColor = "auto")
        {
            var prefix = Path.GetFileNameWithoutExtension(imagePath);
            var args = new string[] {
                "--enable-palettes", "0,1,2,3",
                "-input-0", $"{imagePath}",
                "--out-pattern-table-0", PatternTablePath(prefix, 0),
                "--out-name-table-0", NameTablePath(prefix, 0),
                "--out-attribute-table-0", AttrTablePath(prefix, 0),
                "--out-palette-0", PalettePath(prefix, 0),
                "--out-palette-1", PalettePath(prefix, 1),
                "--out-palette-2", PalettePath(prefix, 2),
                "--out-palette-3", PalettePath(prefix, 3),
                "--bg-color", bgColor,
            };
            var r = Program.Main(args);
            if (r != 0) throw new InvalidOperationException($"Return code: {r}");

            //foreach (var file in Directory.GetFiles(".", "*.bin")) File.Copy(file, Path.Join(@"E:\bins", Path.GetFileName(file)), true);
        }

        public void DoBenchmarkSplit2(string imagePath)
        {
            var prefix = Path.GetFileNameWithoutExtension(imagePath);
            var args = new string[] {
                "--enable-palettes", "0,1,2,3",
                "-input-0", $"{imagePath}:0:128",
                "-input-1", $"{imagePath}:128:112",
                "--out-pattern-table-0", PatternTablePath(prefix, 0),
                "--out-pattern-table-1", PatternTablePath(prefix, 1),
                "--out-name-table-0", NameTablePath(prefix, 0),
                "--out-name-table-1", NameTablePath(prefix, 1),
                "--out-attribute-table-0", AttrTablePath(prefix, 0),
                "--out-attribute-table-1", AttrTablePath(prefix, 1),
                "--out-palette-0", PalettePath(prefix, 0),
                "--out-palette-1", PalettePath(prefix, 1),
                "--out-palette-2", PalettePath(prefix, 2),
                "--out-palette-3", PalettePath(prefix, 3),
            };
            var r = Program.Main(args);
            if (r != 0) throw new InvalidOperationException($"Return code: {r}");

            //foreach (var file in Directory.GetFiles(".", "*.bin")) File.Copy(file, Path.Join(@"E:\bins", Path.GetFileName(file)), true);
        }
        
        public void DoBenchmarkSplit4(string imagePath)
        {
            var prefix = Path.GetFileNameWithoutExtension(imagePath);
            var args = new string[] {
                "--enable-palettes", "0,1,2,3",
                "-input-0", $"{imagePath}:0:64",
                "-input-1", $"{imagePath}:64:64",
                "-input-2", $"{imagePath}:128:64",
                "-input-3", $"{imagePath}:192:48",
                "--out-pattern-table-0", PatternTablePath(prefix, 0),
                "--out-pattern-table-1", PatternTablePath(prefix, 1),
                "--out-pattern-table-2", PatternTablePath(prefix, 2),
                "--out-pattern-table-3", PatternTablePath(prefix, 3),
                "--out-name-table-0", NameTablePath(prefix, 0),
                "--out-name-table-1", NameTablePath(prefix, 1),
                "--out-name-table-2", NameTablePath(prefix, 2),
                "--out-name-table-3", NameTablePath(prefix, 3),
                "--out-attribute-table-0", AttrTablePath(prefix, 0),
                "--out-attribute-table-1", AttrTablePath(prefix, 1),
                "--out-attribute-table-2", AttrTablePath(prefix, 2),
                "--out-attribute-table-3", AttrTablePath(prefix, 3),
                "--out-palette-0", PalettePath(prefix, 0),
                "--out-palette-1", PalettePath(prefix, 1),
                "--out-palette-2", PalettePath(prefix, 2),
                "--out-palette-3", PalettePath(prefix, 3),
            };
            var r = Program.Main(args);
            if (r != 0) throw new InvalidOperationException($"Return code: {r}");

            //foreach (var file in Directory.GetFiles(".", "*.bin")) File.Copy(file, Path.Join(@"E:\bins", Path.GetFileName(file)), true);
        }

    }
}