|
|
@ -1,5 +1,7 @@
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
using MySql.Data.MySqlClient;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DorisTest
|
|
|
|
namespace DorisTest
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -30,11 +32,33 @@ namespace DorisTest
|
|
|
|
// "replication_num" = "1"
|
|
|
|
// "replication_num" = "1"
|
|
|
|
//);
|
|
|
|
//);
|
|
|
|
//insert into test values (0,"user1",20);
|
|
|
|
//insert into test values (0,"user1",20);
|
|
|
|
using var cmd = db.Database.GetDbConnection().CreateCommand();
|
|
|
|
using (var conn = new MySqlConnection("Server=localhost;Port=9030;Database=test;Uid=root;Allow User Variables=True;"))
|
|
|
|
db.Database.OpenConnection();
|
|
|
|
{
|
|
|
|
cmd.CommandText = $"select count(*) from test;";
|
|
|
|
conn.Open();
|
|
|
|
var result = cmd.ExecuteScalar();
|
|
|
|
using (var cmd = conn.CreateCommand())
|
|
|
|
Console.WriteLine(result.ToString());
|
|
|
|
{
|
|
|
|
|
|
|
|
var watch = new Stopwatch();
|
|
|
|
|
|
|
|
watch.Start();
|
|
|
|
|
|
|
|
for (int i = 427383; i < 10000000; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cmd.CommandText += $"insert into pv_bitmap values({i + 1},'{GetChar()}{GetChar()}{GetChar()}',to_bitmap({new Random((int)DateTime.UtcNow.Ticks).Next(1, 100)}));";
|
|
|
|
|
|
|
|
if (i % 100 == 0 || i == 10000000 - 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cmd.ExecuteNonQuery();
|
|
|
|
|
|
|
|
watch.Stop();
|
|
|
|
|
|
|
|
Console.WriteLine(watch.ElapsedMilliseconds + ":" + i.ToString());
|
|
|
|
|
|
|
|
watch = new Stopwatch();
|
|
|
|
|
|
|
|
watch.Start();
|
|
|
|
|
|
|
|
cmd.CommandText = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static char GetChar()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return (char)new Random((int)DateTime.UtcNow.Ticks).Next(97, 122);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|