2,209
社区成员
发帖
与我相关
我的任务
分享
private void button2_Click(object sender, EventArgs e)
{
TimeSpan ts1 = Process.GetCurrentProcess().TotalProcessorTime;
Stopwatch stw = new Stopwatch();
stw.Start();
int i = Int32.Parse(textBox1.Text);
for (int j = 0; j < i; j++)
{
byte[] valArrSet = Encoding.UTF8.GetBytes("aaa" + j.ToString());
redisClient.Set(j.ToString(), valArrSet);
}
double Msecs = Process.GetCurrentProcess().TotalProcessorTime.Subtract(ts1).TotalMilliseconds;
stw.Stop();
label2.Text = textBox1.Text + "个数据存储成功!用时:" + Msecs;
label1.Text = string.Format("循环次数:{0} CPU时间(毫秒)={1} 实际时间(毫秒)={2}", textBox1.Text, Msecs, stw.Elapsed.TotalMilliseconds, stw.ElapsedTicks);
}