Skip to content

Commit d151348

Browse files
committed
Upgrades with news NETStandard.Library 2.0.0-preview
1 parent 9688e96 commit d151348

File tree

5 files changed

+27
-21
lines changed

5 files changed

+27
-21
lines changed

DuplicityKeys.Core.sample/Program.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Diagnostics;
5+
using System.Runtime.InteropServices;
56

67
namespace DuplicityKeys.Core.sample
78
{
89
class Program
910
{
1011
//
12+
[StructLayout(LayoutKind.Sequential, Pack = 1)]
1113
private struct BtnKey
1214
{
1315
public string keyCity;
@@ -45,20 +47,18 @@ static int CmpBtnKey(BtnKey keyX, BtnKey keyY, object objCmp)
4547
static bool FuncUpdate(BtnKey keyAdd, ref BtnKey keyUpdate, object objUpdate)
4648
{
4749
// Resize ?
48-
if (keyUpdate.aValueDateTime.Length <= keyUpdate.valueCount)
50+
if ((keyUpdate.aValueDateTime.Length <= keyUpdate.valueCount) || (keyUpdate.aValueRand.Length <= keyUpdate.valueCount))
4951
{
50-
if (keyUpdate.aValueDateTime.Length >= 1024)
51-
Array.Resize<DateTime>(ref keyUpdate.aValueDateTime, keyUpdate.aValueDateTime.Length + 256);
52+
if ((keyUpdate.aValueDateTime.Length >= 1024) || (keyUpdate.aValueRand.Length >= 1024))
53+
{
54+
Array.Resize<DateTime>(ref keyUpdate.aValueDateTime, keyUpdate.aValueDateTime.Length + 1024);
55+
Array.Resize<uint>(ref keyUpdate.aValueRand, keyUpdate.aValueRand.Length + 1024);
56+
}
5257
else
58+
{
5359
Array.Resize<DateTime>(ref keyUpdate.aValueDateTime, keyUpdate.aValueDateTime.Length * 2);
54-
}
55-
// Resize ?
56-
if (keyUpdate.aValueRand.Length <= keyUpdate.valueCount)
57-
{
58-
if (keyUpdate.aValueRand.Length >= 1024)
59-
Array.Resize<uint>(ref keyUpdate.aValueRand, keyUpdate.aValueRand.Length + 256);
60-
else
6160
Array.Resize<uint>(ref keyUpdate.aValueRand, keyUpdate.aValueRand.Length * 2);
61+
}
6262
}
6363
// Update
6464
keyUpdate.aValueDateTime[keyUpdate.valueCount] = keyAdd.aValueDateTime[0];
@@ -69,7 +69,7 @@ static bool FuncUpdate(BtnKey keyAdd, ref BtnKey keyUpdate, object objUpdate)
6969
//
7070
public static FcsKeyFastBTreeN<BtnKey> CreateFcsKeyFastBTreeN()
7171
{
72-
return new FcsKeyFastBTreeN<BtnKey>(BtnKey.CmpBtnKey, BtnKey.FuncUpdate, 32);
72+
return new FcsKeyFastBTreeN<BtnKey>(CmpBtnKey, FuncUpdate, 32);
7373
}
7474
}
7575
//
@@ -126,12 +126,17 @@ static void Main(string[] args)
126126
}
127127
swFcsKV.Stop();
128128
iMem = GC.GetTotalMemory(true);
129-
Console.WriteLine("UsedMemory {0,5} MB [{1,5:N1} s] | {3} keys | Δ {2,3} MB | {4,8:N0} ns | {5,10:N0} values", iMem >> 20, swFcsKV.Elapsed.TotalSeconds, (iMem - iMemOld) >> 20,
130-
btnTest.BtnUsedKeys(), ((double)(swFcsKV.Elapsed.TotalMilliseconds * 1000000) / iPocetAdd), iPocetAdd);
129+
Console.WriteLine("UsedMemory {0,5} MB [{1,5:N1} s] | {3} keys | Δ {2,3} MB | {4,8:N0} ns | {5,10:N0} values | sizeT {6,2} Byte", iMem >> 20, swFcsKV.Elapsed.TotalSeconds, (iMem - iMemOld) >> 20,
130+
btnTest.BtnUsedKeys(), ((double)(swFcsKV.Elapsed.TotalMilliseconds * 1000000) / iPocetAdd), iPocetAdd, Marshal.SizeOf<BtnKey>());
131131
iMemOld = iMem;
132132
int iCompareCount = 0;
133+
// generate code at run time
134+
foreach (BtnKey? value in btnTest)
135+
iCompareCount++;
136+
//
137+
iCompareCount = 0;
133138
swFcsKV.Restart();
134-
foreach(BtnKey? value in btnTest)
139+
foreach (BtnKey? value in btnTest)
135140
iCompareCount++;
136141
swFcsKV.Stop();
137142
Console.WriteLine("\nFcsKeyFastBTreeN - foreach()");
@@ -140,12 +145,13 @@ static void Main(string[] args)
140145
iCompareCount = 0;
141146
FcsKeyFastBTreeN<BtnKey>.BtnKeyEnumeratorFast btnEn = btnTest.GetEnumeratorFastEx(false);
142147
swFcsKV.Restart();
143-
while(btnEn.MoveNext())
148+
while (btnEn.MoveNext())
144149
{
145150
BtnKey? value = btnEn.Current;
146151
iCompareCount++;
147152
}
148153
swFcsKV.Stop();
154+
btnEn.Dispose();
149155
Console.WriteLine("\nFcsKeyFastBTreeN - foreach()");
150156
Console.WriteLine($"{((double)(swFcsKV.Elapsed.TotalMilliseconds * 1000000) / iCompareCount),9:N2} ns [{swFcsKV.Elapsed.TotalMilliseconds,11} ms | {iCompareCount} keys ]{iCompareCount / swFcsKV.Elapsed.TotalSeconds,20:N0} IOPS");
151157

FriendlyCSharp.Databases/BTreeN/FcsBTreeN.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ public void BtnDeleteAll()
385385
BtnDeleteAll(false);
386386
}
387387
//////////////////////////
388-
public void BtnDeleteAll(bool bRunGC)
388+
public virtual void BtnDeleteAll(bool bRunGC)
389389
{
390390
lock (_btnLockAdd)
391391
{

FriendlyCSharp.Databases/BTreeN/FcsDuplValueFastBTreeN.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public void BtnDeleteAll()
381381
BtnDeleteAll(false);
382382
}
383383
//////////////////////////
384-
public void BtnDeleteAll(bool bRunGC)
384+
public virtual void BtnDeleteAll(bool bRunGC)
385385
{
386386
lock (_btnLockAdd)
387387
{
@@ -1506,7 +1506,7 @@ object IEnumerator.Current
15061506
}
15071507
}
15081508
//////////////////////////
1509-
public void Dispose() { _btn = null; }
1509+
public void Dispose() { _btn = null; _btnFast.Dispose(); }
15101510
//////////////////////////
15111511
public void Reset()
15121512
{

FriendlyCSharp.Databases/BTreeN/FcsFastBTreeN.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ object IEnumerator.Current
459459
}
460460
}
461461
//////////////////////////
462-
public void Dispose() { _btn = null; }
462+
public void Dispose() { _btn = null; _btnFast.Dispose(); }
463463
//////////////////////////
464464
public void Reset()
465465
{

FriendlyCSharp.Databases/BTreeN/FcsKeyFastBTreeN.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ public void BtnDeleteAll()
352352
BtnDeleteAll(false);
353353
}
354354
//////////////////////////
355-
public void BtnDeleteAll(bool bRunGC)
355+
public virtual void BtnDeleteAll(bool bRunGC)
356356
{
357357
lock (_btnLockAdd)
358358
{
@@ -1247,7 +1247,7 @@ object IEnumerator.Current
12471247
}
12481248
}
12491249
//////////////////////////
1250-
public void Dispose() { _btn = null; }
1250+
public void Dispose() { _btn = null; _btnFast.Dispose(); }
12511251
//////////////////////////
12521252
public void Reset()
12531253
{

0 commit comments

Comments
 (0)