当前位置:网站首页>关于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)); } } }
边栏推荐
- Dojo tutorials:getting started with deferrals source code and example execution summary
- Kung Fu pays off, and learning is done
- Simple use and precautions of kotlin's array array and set list
- ncnn神经网络计算框架在香橙派OrangePi 3 LTS开发板中的使用介绍
- 4. 无线体内纳米网:电磁传播模型和传感器部署要点
- 十條職場規則
- 基于Linu开发的项目视频
- Social community forum app ultra-high appearance UI interface
- Kotlin notes - popular knowledge points asterisk (*)
- ORM use of node -serialize
猜你喜欢
[problem exploration and solution of one or more filters or listeners failing to start]
[comprehensive question] [Database Principle]
Four problems and isolation level of MySQL concurrency
Sword finger offer03 Repeated numbers in the array [simple]
Alibaba is bigger than sending SMS (user microservice - message microservice)
Method overloading and rewriting
Application of ncnn Neural Network Computing Framework in Orange Pi 3 Lts Development Board
记录自己vulnhub闯关记录
Sword finger offer09 Implementing queues with two stacks
Gan totem column bridgeless boost PFC (single phase) seven PFC duty cycle feedforward
随机推荐
Export the entire Oracle Database
Loan calculator my pressure is high
(latest version) WiFi distribution multi format + installation framework
Analysis of a music player Login Protocol
Huffman coding experiment report
Brief introduction to mvcc
Sword finger offer03 Repeated numbers in the array [simple]
4. 无线体内纳米网:电磁传播模型和传感器部署要点
[exercise 5] [Database Principle]
T430 toss and install OS majave 10.14
studio All flavors must now belong to a named flavor dimension. Learn more
Application of ncnn neural network computing framework in orange school orangepi 3 lts development board
alright alright alright
阿里 & 蚂蚁自研 IDE
C graphical tutorial (Fourth Edition)_ Chapter 17 generic: genericsamplep315
【数据库原理复习题】
【Colab】【使用外部数据的7种方法】
Four problems and isolation level of MySQL concurrency
Public and private account sending prompt information (user microservice -- message microservice)
Solve the problem of VI opening files with ^m at the end