Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,113 @@ dotnet_diagnostic.IDE0051.severity = none

# IDE0052: 删除未读的私有成员
dotnet_diagnostic.IDE0052.severity = none
end_of_line = crlf
dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent

[*.cs]
#### 命名样式 ####

# 命名规则

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# 符号规范

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# 命名样式

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
csharp_using_directive_placement = outside_namespace:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_conditional_delegate_call = true:suggestion

[*.vb]
#### 命名样式 ####

# 命名规则

dotnet_naming_rule.interface_should_be_以_i_开始.severity = suggestion
dotnet_naming_rule.interface_should_be_以_i_开始.symbols = interface
dotnet_naming_rule.interface_should_be_以_i_开始.style = 以_i_开始

dotnet_naming_rule.类型_should_be_帕斯卡拼写法.severity = suggestion
dotnet_naming_rule.类型_should_be_帕斯卡拼写法.symbols = 类型
dotnet_naming_rule.类型_should_be_帕斯卡拼写法.style = 帕斯卡拼写法

dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.severity = suggestion
dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.symbols = 非字段成员
dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.style = 帕斯卡拼写法

# 符号规范

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.类型.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.类型.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
dotnet_naming_symbols.类型.required_modifiers =

dotnet_naming_symbols.非字段成员.applicable_kinds = property, event, method
dotnet_naming_symbols.非字段成员.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
dotnet_naming_symbols.非字段成员.required_modifiers =

# 命名样式

dotnet_naming_style.以_i_开始.required_prefix = I
dotnet_naming_style.以_i_开始.required_suffix =
dotnet_naming_style.以_i_开始.word_separator =
dotnet_naming_style.以_i_开始.capitalization = pascal_case

dotnet_naming_style.帕斯卡拼写法.required_prefix =
dotnet_naming_style.帕斯卡拼写法.required_suffix =
dotnet_naming_style.帕斯卡拼写法.word_separator =
dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case

dotnet_naming_style.帕斯卡拼写法.required_prefix =
dotnet_naming_style.帕斯卡拼写法.required_suffix =
dotnet_naming_style.帕斯卡拼写法.word_separator =
dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case
33 changes: 0 additions & 33 deletions TYLDDB.Parser.Test/Program.cs

This file was deleted.

15 changes: 0 additions & 15 deletions TYLDDB.Parser.Test/TYLDDB.Parser.Test.csproj

This file was deleted.

89 changes: 83 additions & 6 deletions TYLDDB.Test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using TYLDDB;

string dbFilePath = "./example.lddb";
List<string> testData = [];

///////////////////////////////////////////////////////////////////////////////////////////////////////// 实例化
var lddb = new LDDB();
Expand All @@ -20,7 +21,14 @@
lddb.LoadDatabase("database1");
Console.WriteLine(lddb.GetLoadingDatabaseContent()); // 输出database1内容
loadDbTimer.Stop();
WriteTime("从发起读取数据库指令到成功返回读取内容的总时间为: ", loadDbTimer.ElapsedMilliseconds());
WriteTime("从发起读取数据库指令到成功返回读取内容的总时间为(V1): ", loadDbTimer.ElapsedMilliseconds());

HighPrecisionTimer loadDbV2Timer = new(); // 从发起读取数据库到成功返回读取内容的总时间
loadDbV2Timer.Start();
lddb.LoadDatabase_V2("database1");
Console.WriteLine(lddb.GetLoadingDatabaseContent()); // 输出database1内容
loadDbV2Timer.Stop();
WriteTime("从发起读取数据库指令到成功返回读取内容的总时间为(V2): ", loadDbV2Timer.ElapsedMilliseconds());

///////////////////////////////////////////////////////////////////////////////////////////////////////// 获取所有数据库名称
HighPrecisionTimer readAllDbNameTimer = new(); // 从发起读取数据库名称到成功返回读取内容的总时间
Expand All @@ -37,11 +45,48 @@
WriteTime("从发起读取数据库名称到成功返回读取内容的总时间为: ", readAllDbNameTimer.ElapsedMilliseconds());

///////////////////////////////////////////////////////////////////////////////////////////////////////// 数据库解析缓存
HighPrecisionTimer parseDbTimer = new(); // 从发起解析文件到成功解析并写入缓存的总时间
HighPrecisionTimer parseDbTimer = new(); // 从发起解析文件到成功解析并写入缓存的总时间(同步)
parseDbTimer.Start();
await lddb.ParseAsync();
await lddb.Parse();
parseDbTimer.Stop();
WriteTime("从发起解析文件到成功解析并写入缓存的总时间: ", parseDbTimer.ElapsedMilliseconds());
WriteTime("从发起解析文件到成功解析并写入缓存的总时间(同步): ", parseDbTimer.ElapsedMilliseconds());
HighPrecisionTimer parseDbTimerAsync = new(); // 从发起解析文件到成功解析并写入缓存的总时间(异步)
parseDbTimerAsync.Start();
await lddb.ParseAsync();
parseDbTimerAsync.Stop();
WriteTime("从发起解析文件到成功解析并写入缓存的总时间(异步): ", parseDbTimerAsync.ElapsedMilliseconds());

///////////////////////////////////////////////////////////////////////////////////////////////////////// 并发词典数据库全类型同步搜寻
HighPrecisionTimer allTypeSearchFromConcurrentDictionaryTimer = new();
allTypeSearchFromConcurrentDictionaryTimer.Start();
string[] AllTypeSearchFromConcurrentDictionaryResult = lddb.AllTypeSearchFromConcurrentDictionary("str_name");
allTypeSearchFromConcurrentDictionaryTimer.Stop();
// 使用 foreach 输出数组的每个元素
foreach (var str in AllTypeSearchFromConcurrentDictionaryResult)
{
Console.WriteLine(str);
}
WriteTime("并发词典数据库全类型同步搜寻: ", allTypeSearchFromConcurrentDictionaryTimer.ElapsedMilliseconds());

///////////////////////////////////////////////////////////////////////////////////////////////////////// 信号量线程锁词典数据库全类型同步搜寻
HighPrecisionTimer allTypeSearchFromSemaphoreThreadLockTimer = new();
allTypeSearchFromSemaphoreThreadLockTimer.Start();
string[] AllTypeSearchFromSemaphoreThreadLockResult = lddb.AllTypeSearchFromSemaphoreThreadLock("str_name");
allTypeSearchFromSemaphoreThreadLockTimer.Stop();
// 使用 foreach 输出数组的每个元素
foreach (var str in AllTypeSearchFromSemaphoreThreadLockResult)
{
Console.WriteLine(str);
}
WriteTime("信号量线程锁词典数据库全类型同步搜寻: ", allTypeSearchFromSemaphoreThreadLockTimer.ElapsedMilliseconds());











Expand All @@ -54,13 +99,45 @@






ExportTestData();
Console.ReadLine();

////////////////////////////////////////////////////////////////////////////////////////////////////////// Test Method

///////////////////////////////////////////////////////////////////////////////////////////////////////// 工具
static void WriteTime(string what, double time)
void WriteTime(string what, double time)
{
Console.WriteLine(what + time + "ms\n");
string data = what + time + "ms\n";
Console.WriteLine(data);
AddTestData(data);
Console.WriteLine();
}

void AddTestData(string data)
{
testData.Add(data);
}

void ExportTestData()
{
// 获取当前日期和时间,格式化为 "yyyy-MM-dd HH-mm"
string fileName = DateTime.Now.ToString("yyyy-MM-dd HH-mm") + ".txt";

// 指定文件路径
string directoryPath = "./testdata/";
string filePath = Path.Combine(directoryPath, fileName);

// 确保目录存在,如果不存在则创建
if (!Directory.Exists(directoryPath))
{
Directory.CreateDirectory(directoryPath);
}

// 将 List<string> 中的每一行写入文件
File.WriteAllLines(filePath, testData);

Console.WriteLine($"数据已成功写入文件: {filePath}");
}
2 changes: 2 additions & 0 deletions TYLDDB.Test/TYLDDB.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>True</PublishAot>
<NuGetAudit>False</NuGetAudit>
</PropertyGroup>

<ItemGroup>
Expand Down
11 changes: 5 additions & 6 deletions TYLDDB.Test/example.lddb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
database1::{
string::"str_name"="name1";
string::"str_name"="name1 space test";
int::"int_value"="123";
short::"short_value"="32767";
long::"long_value"="2147483647";
float::"float_value"="3.14f";
float::"float_value"="3.14";
double::"double_value"="3.141592653589793";
boolean::"bool"="true";
char::"char_value"="127";
decimal::decima_value = 19.99m";
internaldb::"db_name"={};
char::"char_value"="A";
decimal::decimal_value = 19.99";
distributeddb::"distributed_db_name"="./example.lddb";
};
database2::{
Expand All @@ -20,7 +19,7 @@ database2::{
double::"double_value"="3.141592653589793"
boolean::"bool"="true"
char::"char_value"="127"
decimal::decima_value = 19.99m"
decimal::decimal_value = 19.99m"
internaldb::"db_name"={};
distributeddb::"distributed_db_name"="./example.lddb";
};
Expand Down
37 changes: 0 additions & 37 deletions TYLDDB.Utils.Writer.Test/Program.cs

This file was deleted.

15 changes: 0 additions & 15 deletions TYLDDB.Utils.Writer.Test/TYLDDB.Utils.Writer.Test.csproj

This file was deleted.

Loading
Loading