当前位置:网站首页>关于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));
}
}
}边栏推荐
- [review questions of database principles]
- Analysis of the influence of voltage loop on PFC system performance
- Idea packages the web project into a war package and deploys it to the server to run
- Openstack node address change
- 最新版盲盒商城thinkphp+uniapp
- With pictures and texts, summarize the basic review of C language in detail, so that all kinds of knowledge points are clear at a glance?
- [exercise 7] [Database Principle]
- Xctf mobile--app3 problem solving
- Project video based on Linu development
- 并网-低电压穿越与孤岛并存分析
猜你喜欢
![[review questions of database principles]](/img/c3/81d192a40bcc4f5d72fcbe76c708bb.png)
[review questions of database principles]

基于同步坐标变换的谐波电流检测

Social community forum app ultra-high appearance UI interface

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

Xctf mobile--app1 problem solving
![[comprehensive question] [Database Principle]](/img/d7/8c51306bb390e0383a017d9097e1e5.png)
[comprehensive question] [Database Principle]

阿里大于发送短信(用户微服务--消息微服务)

Analysis of the influence of voltage loop on PFC system performance

自抗扰控制器七-二阶 LADRC-PLL 结构设计

initial、inherit、unset、revert和all的区别
随机推荐
idea将web项目打包成war包并部署到服务器上运行
最新版抽奖盲盒运营版
Swift5.7 extend some to generic parameters
The foreground uses RSA asymmetric security to encrypt user information
Tensorflow binary installation & Failure
Low code platform international multilingual (I18N) technical solution
Xctf mobile--app3 problem solving
Swift return type is a function of function
Node.js: express + MySQL的使用
[Exercice 5] [principe de la base de données]
The latest version of lottery blind box operation version
Keep learning swift
最新版盲盒商城thinkphp+uniapp
Comprehensive evaluation of double chain notes · Siyuan notes: advantages, disadvantages and evaluation
How to convert a decimal number to binary in swift
Solve the problem of VI opening files with ^m at the end
4. Wireless in vivo nano network: electromagnetic propagation model and key points of sensor deployment
RedHat5 安装Socket5代理服务器
[comprehensive question] [Database Principle]
Express abstract classes and methods