You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/labs/doris/DorisTest/Program.cs

64 lines
2.2 KiB

using Microsoft.EntityFrameworkCore;
using MySql.Data.MySqlClient;
using System;
using System.Diagnostics;
namespace DorisTest
{
public class TestContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMySql("Server=localhost;Port=9030;Database=test;Uid=root;Allow User Variables=True;");
}
}
internal class Program
{
private static void Main(string[] args)
{
using var db = new TestContext();
//create database test;
//use test;
//create table test
//(
// userid bigint,
// username varchar(32),
// amount bigint default '0'
//)
//unique key(userid)
//distributed by hash(userid) buckets 1
//properties(
// "replication_num" = "1"
//);
//insert into test values (0,"user1",20);
using (var conn = new MySqlConnection("Server=localhost;Port=9030;Database=test;Uid=root;Allow User Variables=True;"))
{
conn.Open();
using (var cmd = conn.CreateCommand())
{
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);
}
}
}