1
0
mirror of synced 2025-12-24 14:07:57 +08:00

auto commit

This commit is contained in:
yitter
2021-04-05 12:24:51 +08:00
parent 25dfa94d21
commit 40c95cf763
8 changed files with 0 additions and 340 deletions

View File

@@ -24,22 +24,6 @@ namespace Yitter.OrgSystem.TestA
static int workerCount = 1;
//[DllImport("yitidgenc.dll", CallingConvention = CallingConvention.StdCall)]
//public static extern long NextId();
[DllImport("yitidgengo.dll", EntryPoint = "NextId", CallingConvention = CallingConvention.StdCall)]
public static extern long NextId2();
[DllImport("yitidgengo.so", EntryPoint = "NextId", CallingConvention = CallingConvention.StdCall)]
public static extern long NextId();
[DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)]
public static extern void SetWorkerId(uint workerId);
[DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int TestId();
static void Main(string[] args)
{
Console.WriteLine("Hello World! C#");
@@ -77,46 +61,6 @@ namespace Yitter.OrgSystem.TestA
}
}
private static void CallDll()
{
try
{
int i = 0;
long id = 0;
DateTime start = DateTime.Now;
bool useMultiThread = false;
//var ids = TestId();
//SetWorkerId(1);
while (i < 50000)
{
i++;
if (useMultiThread)
{
Task.Run(() =>
{
id = NextId();
Console.WriteLine("id" + id);
});
}
else
{
id = NextId();
}
}
DateTime end = DateTime.Now;
Console.WriteLine("id:" + id);
Console.WriteLine($"+++++++++++C# call rust dll, gen 5W, total: {(end - start).TotalMilliseconds} ms");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
private static void RunSingle()
{
DateTime start = DateTime.Now;