first commit from linux

This commit is contained in:
2022-01-18 19:41:07 +03:00
parent 920ae8ca88
commit 749b5f1af1
82 changed files with 36040 additions and 4609 deletions

View File

@@ -1,89 +1,89 @@
using System.Threading;
using DTLib.Dtsod;
using DTLib.Experimental;
using static TestProgram.Program;
namespace TestProgram.DtsodV2X;
public static class TestDtsodV23
{
public static void TestAll()
{
TestBaseTypes();
TestLists();
TestComplexes();
TestReSerialization();
TestSpeed();
TestMemoryConsumption();
}
public static void TestBaseTypes()
{
Info.Log("b", "[TestDtsodV23/TestBaseTypes]");
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\base_types.dtsod"));
foreach (var pair in dtsod)
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key + ' ', "c", pair.Value.ToString());
Info.Log("g", "[test completed]");
}
public static void TestLists()
{
Info.Log("b", "[TestDtsodV23/TestLists]");
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\lists.dtsod"));
foreach (var pair in dtsod)
{
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key, "c",
$" count: {pair.Value.Count}");
foreach (var el in pair.Value)
Info.LogNoTime("b", '\t'+el.GetType().Name + ' ', "c", el.ToString());
}
Info.Log("g", "[test completed]");
}
public static void TestComplexes()
{
Info.Log("b", "[TestDtsodV23/TestComplexes]");
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\complexes.dtsod"));
foreach (var pair in dtsod)
{
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key,
"b", " length: ", "c", pair.Value.Keys.Count.ToString() + "\n\t",
"y", pair.Value.ToString().Replace("\n","\n\t"));
}
Info.Log("g", "[test completed]");
}
public static void TestReSerialization()
{
Info.Log("b", "[TestDtsodV23/TestReSerialization]");
DtsodV23 dtsod = new DtsodV23(new DtsodV23(new DtsodV23(
new DtsodV23(File.ReadAllText("DtsodV2X\\complexes.dtsod")).ToString()).ToString()).ToString());
Info.Log("y", dtsod.ToString());
Info.Log("g", "[test completed]");
}
public static void TestSpeed()
{
Info.Log("b", "[TestDtsodV23/TestSpeed]");
IDtsod dtsod=null;
string text = File.ReadAllText("DtsodV2X\\messages.dtsod");
Tester.LogOperationTime("V21 deserialization",100,()=>dtsod=new DtsodV21(text));
Tester.LogOperationTime("V21 serialization", 100, () => _=dtsod.ToString());
Tester.LogOperationTime("V23 deserialization", 100, () => dtsod = new DtsodV23(text));
Tester.LogOperationTime("V23 serialization", 100, () => _ = dtsod.ToString());
Info.Log("g", "[test completed]");
}
public static void TestMemoryConsumption()
{
Info.Log("b", "[TestDtsodV23/TestMemoryConsumption]");
string text = File.ReadAllText("DtsodV2X\\messages.dtsod");
var a = GC.GetTotalMemory(true);
DtsodV23[] dtsods = new DtsodV23[100];
for (int i = 0; i < dtsods.Length; i++)
dtsods[i] = new(text);
var b = GC.GetTotalMemory(true);
Info.Log("b", "at the start: ","c",$"{a/1024} kb\n",
"b", "at the end: ", "c", $"{b / 1024} kb\n{dtsods.Count()}","b"," dtsods initialized");
Info.Log("g", "[test completed]");
}
}
using System.Threading;
using DTLib.Dtsod;
using DTLib.Experimental;
using static TestProgram.Program;
namespace TestProgram.DtsodV2X;
public static class TestDtsodV23
{
public static void TestAll()
{
TestBaseTypes();
TestLists();
TestComplexes();
TestReSerialization();
TestSpeed();
TestMemoryConsumption();
}
public static void TestBaseTypes()
{
Info.Log("b", "[TestDtsodV23/TestBaseTypes]");
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\base_types.dtsod"));
foreach (var pair in dtsod)
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key + ' ', "c", pair.Value.ToString());
Info.Log("g", "[test completed]");
}
public static void TestLists()
{
Info.Log("b", "[TestDtsodV23/TestLists]");
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\lists.dtsod"));
foreach (var pair in dtsod)
{
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key, "c",
$" count: {pair.Value.Count}");
foreach (var el in pair.Value)
Info.LogNoTime("b", '\t'+el.GetType().Name + ' ', "c", el.ToString());
}
Info.Log("g", "[test completed]");
}
public static void TestComplexes()
{
Info.Log("b", "[TestDtsodV23/TestComplexes]");
DtsodV23 dtsod = new(File.ReadAllText("DtsodV2X\\complexes.dtsod"));
foreach (var pair in dtsod)
{
Info.LogNoTime("b", pair.Value.GetType().Name + ' ', "w", pair.Key,
"b", " length: ", "c", pair.Value.Keys.Count.ToString() + "\n\t",
"y", pair.Value.ToString().Replace("\n","\n\t"));
}
Info.Log("g", "[test completed]");
}
public static void TestReSerialization()
{
Info.Log("b", "[TestDtsodV23/TestReSerialization]");
DtsodV23 dtsod = new DtsodV23(new DtsodV23(new DtsodV23(
new DtsodV23(File.ReadAllText("DtsodV2X\\complexes.dtsod")).ToString()).ToString()).ToString());
Info.Log("y", dtsod.ToString());
Info.Log("g", "[test completed]");
}
public static void TestSpeed()
{
Info.Log("b", "[TestDtsodV23/TestSpeed]");
IDtsod dtsod=null;
string text = File.ReadAllText("DtsodV2X\\messages.dtsod");
Tester.LogOperationTime("V21 deserialization",100,()=>dtsod=new DtsodV21(text));
Tester.LogOperationTime("V21 serialization", 100, () => _=dtsod.ToString());
Tester.LogOperationTime("V23 deserialization", 100, () => dtsod = new DtsodV23(text));
Tester.LogOperationTime("V23 serialization", 100, () => _ = dtsod.ToString());
Info.Log("g", "[test completed]");
}
public static void TestMemoryConsumption()
{
Info.Log("b", "[TestDtsodV23/TestMemoryConsumption]");
string text = File.ReadAllText("DtsodV2X\\messages.dtsod");
var a = GC.GetTotalMemory(true);
DtsodV23[] dtsods = new DtsodV23[100];
for (int i = 0; i < dtsods.Length; i++)
dtsods[i] = new(text);
var b = GC.GetTotalMemory(true);
Info.Log("b", "at the start: ","c",$"{a/1024} kb\n",
"b", "at the end: ", "c", $"{b / 1024} kb\n{dtsods.Count()}","b"," dtsods initialized");
Info.Log("g", "[test completed]");
}
}

View File

@@ -1,14 +1,14 @@
bool: false;
char: 'v';
byte: 255b;
sbyte: -125sb;
short: 14003s;
ushort: 32025us;
int: -2515;
uint: 0u;
long: -29863854396l;
ulong: 87659057946ul;
float: 39.944f;
double: 965.557;
decimal: -84.20de;
string: "_$\"\\\\'''\n\ta ûûû000;2;=:%d;```";
bool: false;
char: 'v';
byte: 255b;
sbyte: -125sb;
short: 14003s;
ushort: 32025us;
int: -2515;
uint: 0u;
long: -29863854396l;
ulong: 87659057946ul;
float: 39.944f;
double: 965.557;
decimal: -84.20de;
string: "_$\"\\\\'''\n\ta ûûû000;2;=:%d;```";

View File

@@ -1,4 +1,4 @@
chars: ['a','b','c'];
uints: [10,20,30,0,0];
floats: [8.2,5.225,-0.9993];
chars: ['a','b','c'];
uints: [10,20,30,0,0];
floats: [8.2,5.225,-0.9993];
strings:["aaa","bbb","ccc"];

View File

@@ -1,14 +1,14 @@
bool:b=false;
char:c='v';
string:s="hello";
byte:by=255;
sbyte:sb=-125;
short:sh=14003;
ushort:us=32025;
int:i=-2515;
uint:ui=0;
long:l=-29863854396;
ulong:ul=87659057946;
float:f=39.944;
double:do=965.557;
bool:b=false;
char:c='v';
string:s="hello";
byte:by=255;
sbyte:sb=-125;
short:sh=14003;
ushort:us=32025;
int:i=-2515;
uint:ui=0;
long:l=-29863854396;
ulong:ul=87659057946;
float:f=39.944;
double:do=965.557;
decimal:de=-84.20;

View File

@@ -1 +1 @@
List<string>:list=[string:"a",string:"b"];
List<string>:list=[string:"a",string:"b"];

View File

@@ -1,36 +1,36 @@
global using System;
global using System.Collections;
global using System.Collections.Generic;
global using System.Linq;
global using System.Text;
global using System.Threading.Tasks;
global using DTLib;
global using DTLib.Extensions;
global using DTLib.Filesystem;
using DTLib.Dtsod;
using DTLib.Loggers;
using TestProgram.DtsodV2X;
namespace TestProgram;
static class Program
{
public static DefaultLogger Info = new();
static public void Main()
{
Info.Enable();
PublicLog.LogEvent += Info.Log;
PublicLog.LogNoTimeEvent += Info.LogNoTime;
Console.OutputEncoding = Encoding.UTF8;
Console.InputEncoding = Encoding.UTF8;
Console.Title="tester";
try
{
TestDtsodV23.TestAll();
}
catch (Exception ex)
{ Info.Log("r", ex.ToString()); }
Console.ResetColor();
}
global using System;
global using System.Collections;
global using System.Collections.Generic;
global using System.Linq;
global using System.Text;
global using System.Threading.Tasks;
global using DTLib;
global using DTLib.Extensions;
global using DTLib.Filesystem;
using DTLib.Dtsod;
using DTLib.Loggers;
using TestProgram.DtsodV2X;
namespace TestProgram;
static class Program
{
public static DefaultLogger Info = new();
static public void Main()
{
Info.Enable();
PublicLog.LogEvent += Info.Log;
PublicLog.LogNoTimeEvent += Info.LogNoTime;
Console.OutputEncoding = Encoding.UTF8;
Console.InputEncoding = Encoding.UTF8;
Console.Title="tester";
try
{
TestDtsodV23.TestAll();
}
catch (Exception ex)
{ Info.Log("r", ex.ToString()); }
Console.ResetColor();
}
}

View File

@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>false</ImplicitUsings>
<Nullable>disable</Nullable>
<DebugType>portable</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<StartupObject>TestProgram.Program</StartupObject>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DTLib\DTLib.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="DtsodV2X\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="DtsodV30\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>false</ImplicitUsings>
<Nullable>disable</Nullable>
<DebugType>portable</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<StartupObject>TestProgram.Program</StartupObject>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DTLib\DTLib.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="DtsodV2X\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="DtsodV30\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>