Skip to content

Commit 4493775

Browse files
committed
Merge from database
2 parents 16162ec + bdb53f7 commit 4493775

File tree

87 files changed

+5325
-496
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+5325
-496
lines changed

Benchmark/Program.cs

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using BenchmarkDotNet.Attributes;
5+
using BenchmarkDotNet.Configs;
6+
using BenchmarkDotNet.Jobs;
7+
using BenchmarkDotNet.Running;
8+
using BenchmarkDotNet.Toolchains.CsProj;
9+
using PapyrusCs.Database;
10+
11+
namespace Benchmark
12+
{
13+
//[CoreJob(), RyuJitX64Job]
14+
//[Config(typeof(Config))]
15+
public class Benchmarks
16+
{
17+
private class Config : ManualConfig
18+
{
19+
public Config()
20+
{
21+
Add(Job.Core.With(CsProjCoreToolchain.NetCoreApp22));
22+
Add(Job.Core.With(CsProjCoreToolchain.NetCoreApp30));
23+
Add(Job.Clr);
24+
}
25+
}
26+
27+
byte[] data = new byte[10];
28+
private byte[][] keys;
29+
private List<byte[]> selectedKeys;
30+
31+
Dictionary<LevelDbWorldKey, UInt32> dict1;
32+
Dictionary<LevelDbWorldKey2, UInt32> dict2;
33+
Dictionary<LevelDbWorldKey3, UInt32> dict3;
34+
35+
36+
[GlobalSetup]
37+
public void Setup()
38+
{
39+
dict1 = new Dictionary<LevelDbWorldKey, uint>();
40+
dict2 = new Dictionary<LevelDbWorldKey2, uint>();
41+
dict3 = new Dictionary<LevelDbWorldKey3, uint>();
42+
43+
selectedKeys = new List<byte[]>();
44+
45+
var random = new Random(132);
46+
keys = new byte[1000000][];
47+
for (int i = 0; i < keys.GetLength(0); i++)
48+
{
49+
keys[i] = new byte[10];
50+
random.NextBytes(keys[i]);
51+
52+
var r = (uint) random.Next();
53+
54+
dict1.Add(new LevelDbWorldKey(keys[i]), r);
55+
dict2.Add(new LevelDbWorldKey2(keys[i]), r);
56+
dict3.Add(new LevelDbWorldKey3(keys[i]), r);
57+
}
58+
59+
for (int i = 0; i < 500000;i++)
60+
{
61+
var key = keys[random.Next(0, 500000)];
62+
selectedKeys.Add(key);
63+
}
64+
65+
checkSumSum1 = 0;
66+
checkSumSum2 = 0;
67+
checkSumSum3 = 0;
68+
}
69+
70+
ulong checkSumSum1 = 0;
71+
ulong checkSumSum2 = 0;
72+
ulong checkSumSum3 = 0;
73+
74+
[GlobalCleanup]
75+
public void Teardown()
76+
{
77+
Console.WriteLine($"First Key {string.Join(" ", selectedKeys.First())}, last Key {string.Join(" ",selectedKeys.Last())}");
78+
Console.WriteLine("1: "+ checkSumSum1);
79+
Console.WriteLine("2: " + checkSumSum2);
80+
Console.WriteLine("3: " + checkSumSum3);
81+
}
82+
83+
[Benchmark]
84+
public void GetChecksums1()
85+
{
86+
if (selectedKeys.Count == 0)
87+
{
88+
throw new ArgumentOutOfRangeException();
89+
}
90+
foreach (var key in selectedKeys)
91+
{
92+
var dbKey = new LevelDbWorldKey(key);
93+
94+
if (dict1.TryGetValue(dbKey, out uint checkSum))
95+
{
96+
checkSumSum1 += checkSum;
97+
}
98+
99+
}
100+
}
101+
102+
[Benchmark]
103+
public void GetChecksums2()
104+
{
105+
foreach (var key in selectedKeys)
106+
{
107+
var dbKey = new LevelDbWorldKey2(key);
108+
109+
if (dict2.TryGetValue(dbKey, out uint checkSum))
110+
{
111+
checkSumSum2 += checkSum;
112+
}
113+
114+
}
115+
}
116+
117+
[Benchmark]
118+
public void GetChecksums3()
119+
{
120+
foreach (var key in selectedKeys)
121+
{
122+
var dbKey = new LevelDbWorldKey3(key);
123+
124+
if (dict3.TryGetValue(dbKey, out uint checkSum))
125+
{
126+
checkSumSum3 += checkSum;
127+
}
128+
129+
}
130+
}
131+
//[Benchmark]
132+
public void InstaciateTest1()
133+
{
134+
LevelDbWorldKey k = new LevelDbWorldKey(data);
135+
}
136+
137+
138+
//[Benchmark]
139+
public void InstaciateTest2()
140+
{
141+
LevelDbWorldKey2 k = new LevelDbWorldKey2(data);
142+
}
143+
144+
//[Benchmark]
145+
public void InstaciateTest3()
146+
{
147+
LevelDbWorldKey3 k = new LevelDbWorldKey3(data);
148+
}
149+
}
150+
151+
class Program
152+
{
153+
static void Main(string[] args)
154+
{
155+
BenchmarkRunner.Run<Benchmarks>();
156+
}
157+
}
158+
}

Imazen.WebP-std/Extern/Constants.cs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
#pragma warning disable 1591
5+
namespace Imazen.WebP.Extern {
6+
public partial class NativeMethods {
7+
8+
/// WEBP_DECODER_ABI_VERSION 0x0208 // MAJOR(8b) + MINOR(8b)
9+
public const int WEBP_DECODER_ABI_VERSION = 520;
10+
11+
/// WEBP_ENCODER_ABI_VERSION 0x0209 // MAJOR(8b) + MINOR(8b)
12+
public const int WEBP_ENCODER_ABI_VERSION = 521;
13+
14+
/// <summary>
15+
/// The maximum length of any dimension of a WebP image is 16383
16+
/// </summary>
17+
public const int WEBP_MAX_DIMENSION = 16383;
18+
}
19+
}
20+
#pragma warning restore 1591

0 commit comments

Comments
 (0)