当前位置:网站首页>关于CPU缓冲行的理解
关于CPU缓冲行的理解
2022-07-03 12:06:00 【aslia】
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
namespace Buff
{
// [StructLayout(LayoutKind.Explicit, Size = 120)]
// class Tclass
// {
// [FieldOffset(56)]
// public long x = 0l;
// }
class Tclass
{
public long x = 0l;
}
internal class T01_CacheLinePadding
{
public static Tclass[] arr = new Tclass[2];
public static long COUNT = 10_0000_0000l;
public static System.DateTime startTime;
public static void Main(string[] args)
{
arr[0] = new Tclass();
arr[1] = new Tclass();
startTime = System.DateTime.Now;
//Run();
RunOne();
}
public static void RunOne()
{
for (int j = 0; j < COUNT; j++)
{
arr[0].x = j;
arr[1].x = j;
}
DateTime dt2 = System.DateTime.Now;
TimeSpan ts = dt2.Subtract(startTime);
Console.WriteLine(string.Format("当前t1的时间:{0}",ts.TotalMilliseconds));
}
public static void Run()
{
List<ManualResetEvent> list = new List<ManualResetEvent>();
ManualResetEvent mre = new ManualResetEvent(false);
System.Threading.Thread thread = new Thread((o) =>
{
for (int j = 0; j < COUNT; j++)
{
arr[0].x = j;
}
((ManualResetEvent)o).Set();
});
System.Threading.Thread thread1 = new Thread((o) =>
{
for (int j = 0; j < COUNT; j++)
{
arr[1].x = j;
}
((ManualResetEvent)o).Set();
});
list.Add(mre);
thread.Start(mre);
thread1.Start(mre);
WaitHandle.WaitAll(list.ToArray());
DateTime dt2 = System.DateTime.Now;
TimeSpan ts = dt2.Subtract(startTime);
Console.WriteLine(string.Format("当前t1的时间:{0}",ts.TotalMilliseconds));
}
}
}边栏推荐
- 最新版盲盒商城thinkphp+uniapp
- Differences between initial, inherit, unset, revert and all
- Idea packages the web project into a war package and deploys it to the server to run
- Tensorflow binary installation & Failure
- 【计网】第三章 数据链路层(2)流量控制与可靠传输、停止等待协议、后退N帧协议(GBN)、选择重传协议(SR)
- 双链笔记·思源笔记综合评测:优点、缺点、评价
- (最新版) Wifi分销多开版+安装框架
- Four problems and isolation level of MySQL concurrency
- 基于Linu开发的项目视频
- 【数据库原理复习题】
猜你喜欢

Swift bit operation exercise

GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈

【Colab】【使用外部数据的7种方法】

【数据库原理及应用教程(第4版|微课版)陈志泊】【第六章习题】

Seven second order ladrc-pll structure design of active disturbance rejection controller

Xctf mobile--rememberother problem solving

Ali & ant self developed IDE

并网-低电压穿越与孤岛并存分析

【数据库原理复习题】

2021 autumn Information Security Experiment 1 (password and hiding technology)
随机推荐
Differences and connections between final and static
2021 autumn Information Security Experiment 1 (password and hiding technology)
Project video based on Linu development
C graphical tutorial (Fourth Edition)_ Chapter 13 entrustment: delegatesamplep245
A large select drop-down box, village in Chaoyang District
Create a dojo progress bar programmatically: Dojo ProgressBar
ImportError: No module named examples. tutorials. mnist
Loan calculator my pressure is high
Simple use and precautions of kotlin's array array and set list
Kung Fu pays off, and learning is done
Record your vulnhub breakthrough record
Integer case study of packaging
【数据库原理及应用教程(第4版|微课版)陈志泊】【第六章习题】
It feels great to know you learned something, isn‘t it?
【习题七】【数据库原理】
[comprehensive question] [Database Principle]
并网-低电压穿越与孤岛并存分析
RedHat5 安装Socket5代理服务器
ncnn神經網絡計算框架在香柳丁派OrangePi 3 LTS開發板中的使用介紹
Apache Mina Development Manual