forked from ddrilling/AsbCloudServer
84 lines
2.8 KiB
C#
84 lines
2.8 KiB
C#
namespace DataTable
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(/*string[] args*/)
|
|
{
|
|
//var listDtos = new List<TestDto>(100);
|
|
|
|
/* *** Size of TestDto calc ***
|
|
*
|
|
* ** data binary size (Not implemented) **
|
|
* Date : DateTime : 4b
|
|
* Mode : int32? : 4b
|
|
* User : string : 2-64b
|
|
* WellDepth : double? : 8b
|
|
* TOTAL data size = 18-80b
|
|
*
|
|
* ** header binary size (Not implemented) **
|
|
*
|
|
*DateTime : len("DateTime") + 2 + len("Date") + 2 = 16b
|
|
* Mode : 14b
|
|
* User : 14b
|
|
* WellDepth : 20b
|
|
* columnsCount : 2b
|
|
* TOTAL header size = 66b
|
|
*
|
|
* ** json as tab **
|
|
*
|
|
* header size: 137b
|
|
* json row size: 63b
|
|
*
|
|
* total for 1 record : 200b
|
|
* total for 2 records : 263b
|
|
*
|
|
* ** json as list **
|
|
*
|
|
* Raw listItem size: 175b
|
|
* total for 2 records : 350b
|
|
*
|
|
* ** example 100 records **
|
|
* tabJsonBytes: 6602
|
|
* listJsonBytes: 9628
|
|
* tabBinBytes: 7765 (by dangerous BinaryFormatter)
|
|
* listBinBytes: 4366 (by dangerous BinaryFormatter)
|
|
*/
|
|
|
|
//for (int i = 0; i < 100; i++)
|
|
// listDtos.Add(new TestDto{
|
|
// Date = DateTime.Now.AddSeconds(i),
|
|
// Mode = 1,
|
|
// WellDepth = i * Math.PI
|
|
// });
|
|
|
|
//var tMapper = new TableMapper<TestDto>();
|
|
|
|
//var tab = tMapper.MakeTable(listDtos);
|
|
|
|
//var e = tMapper.AsEnumerable(tab);
|
|
|
|
//var tabJson = JsonSerializer.Serialize(tab);
|
|
//var listJson = JsonSerializer.Serialize(listDtos);
|
|
|
|
//var tabJsonBytes = JsonSerializer.SerializeToUtf8Bytes(tab);
|
|
//var listJsonBytes = JsonSerializer.SerializeToUtf8Bytes(listDtos);
|
|
|
|
//var formatter = new BinaryFormatter();
|
|
//var mem = new MemoryStream();
|
|
//formatter.Serialize(mem, tab);
|
|
//var tabBinBytes = new byte[mem.Length];
|
|
//Array.Copy(mem.GetBuffer(), tabBinBytes, mem.Length);
|
|
|
|
//mem = new MemoryStream();
|
|
//formatter.Serialize(mem, listDtos);
|
|
//var listBinBytes = new byte[mem.Length];
|
|
//Array.Copy(mem.GetBuffer(), listBinBytes, mem.Length);
|
|
|
|
//Console.WriteLine($"tabJsonBytes:{tabJsonBytes.Length}");
|
|
//Console.WriteLine($"listJsonBytes:{listJsonBytes.Length}");
|
|
//Console.WriteLine($"tabBinBytes:{tabBinBytes.Length}");
|
|
//Console.WriteLine($"listBinBytes:{listBinBytes.Length}");
|
|
}
|
|
}
|
|
}
|