此工具LUYIKK 编写 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Threading; using System.Management; namespace WindowsApplication1 ... { public delegate void whowmess(long e); public partial class Form1 : Form ...{ public event whowmess news; public Form1() ...{ InitializeComponent(); news += new whowmess(Form1_news); } void Form1_news(long e) ...{ this.label2.BeginInvoke(new System.EventHandler(UpdateUI), e); } private void UpdateUI(object o, System.EventArgs e) ...{ this.label2.Text = (2500000000 / burs).ToString() + "分"; this.label1.Text = burs.ToString() + "微秒"; } long burs = 0; private void button1_Click(object sender, EventArgs e) ...{ burs = 0; Thread a = new Thread(new ThreadStart(strat)); a.Start(); Thread b = new Thread(new ThreadStart(strat)); b.Start(); } private void strat() ...{ for (int j = 0; j < 5; j++) ...{ long f = DateTime.Now.Ticks; double c = 100000.123; double b = 200000.021; double ef = 300000.321; for (int i = 0; i < 10000000; i++) ...{ ef = c * b + ef / c - b; } long g = DateTime.Now.Ticks; long kl = g - f; burs += kl; } if (news != null) ...{ news(burs); } } private void timer1_Tick(object sender, EventArgs e) ...{ } private void label1_Click(object sender, EventArgs e) ...{ } private void Form1_Load(object sender, EventArgs e) ...{ int k = 0; String MyInfo = "CPU型号:"; ManagementObjectSearcher MySearcher = new ManagementObjectSearcher("SELECT * FROM Win32_Processor"); foreach (ManagementObject MyObject in MySearcher.Get()) ...{ k++; MyInfo += " " + String.Format("CPU" + k.ToString() + " : " + MyObject["Name"].ToString()); } this.label6.Text = MyInfo; k = 0; String MyInfo2 = "CPU的最大时钟频率:"; foreach (ManagementObject MyObject in MySearcher.Get()) ...{ k++; try ...{ MyInfo2 += " " + String.Format("CPU" + k.ToString() + " : " + MyObject["MaxClockSpeed"].ToString()); } catch ...{ MyInfo2 = "CPU的最大时钟频率:无法获取"; } } this.label7.Text = MyInfo2; k = 0; String MyInfo3 = "CPU地址宽度:"; foreach (ManagementObject MyObject in MySearcher.Get()) ...{ k++; try ...{ MyInfo3 += " " + String.Format("CPU" + k.ToString() + " : " + MyObject["AddressWidth"].ToString()); } catch ...{ MyInfo3 = "CPU地址宽度::无法获取"; } } this.label8.Text = MyInfo3; String MyInfo4 = "CPU数据宽度:"; k = 0; foreach (ManagementObject MyObject in MySearcher.Get()) ...{ k++; try ...{ MyInfo4 += " " + String.Format("CPU" + k.ToString() + " : " + MyObject["AddressWidth"].ToString()); } catch ...{ MyInfo4 = "CPU数据宽度:::无法获取"; } } this.label9.Text = MyInfo4; String MyInfo5 = "CPU的当前电压:"; k = 0; foreach (ManagementObject MyObject in MySearcher.Get()) ...{ k++; try ...{ double x = double.Parse(MyObject["CurrentVoltage"].ToString())/10; MyInfo5 += " " + String.Format("CPU" + k.ToString() + " : " + x.ToString() + "V"); } catch ...{ MyInfo5 = "CPU的当前电压::::无法获取"; } } this.label10.Text = MyInfo5; String MyInfo6 = "CPU的二级缓存:"; k = 0; foreach (ManagementObject MyObject in MySearcher.Get()) ...{ k++; try ...{ MyInfo6 += " " + String.Format("CPU" + k.ToString() + " : " + MyObject["L2CacheSize"].ToString() + "K"); } catch ...{ MyInfo5 = "CPU的二级缓存:无法获取"; } } this.label11.Text = MyInfo6; } }} Form1.Designer.cs namespace WindowsApplication1 ... { partial class Form1 ...{ /**//// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /**//// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) ...{ if (disposing && (components != null)) ...{ components.Dispose(); } base.Dispose(disposing); } Windows 窗体设计器生成的代码#region Windows 窗体设计器生成的代码 /**//// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() ...{ this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.button1 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.timer1 = new System.Windows.Forms.Timer(this.components); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(147, 182); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(116, 23); this.button1.TabIndex = 0; this.button1.Text = "浮点运算测试"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(14, 226); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 12); this.label1.TabIndex = 1; this.label1.Click += new System.EventHandler(this.label1_Click); // // timer1 // this.timer1.Interval = 1000; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(346, 226); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(0, 12); this.label2.TabIndex = 2; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(2, 207); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(113, 12); this.label3.TabIndex = 3; this.label3.Text = "10亿次浮点运算+-*/"; // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(331, 207); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(53, 12); this.label4.TabIndex = 4; this.label4.Text = "总体得分"; // // label5 // this.label5.AutoSize = true; this.label5.ForeColor = System.Drawing.Color.DeepSkyBlue; this.label5.Location = new System.Drawing.Point(74, 3); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(227, 12); this.label5.TabIndex = 5; this.label5.Text = "Windows Vista 双核处理器浮点运算测试"; // // label6 // this.label6.AutoSize = true; this.label6.ForeColor = System.Drawing.Color.CornflowerBlue; this.label6.Location = new System.Drawing.Point(14, 27); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(53, 12); this.label6.TabIndex = 6; this.label6.Text = "CPU型号:"; // // label7 // this.label7.AutoSize = true; this.label7.ForeColor = System.Drawing.Color.CornflowerBlue; this.label7.Location = new System.Drawing.Point(14, 48); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(113, 12); this.label7.TabIndex = 7; this.label7.Text = "CPU的最大时钟频率:"; // // label8 // this.label8.AutoSize = true; this.label8.ForeColor = System.Drawing.Color.CornflowerBlue; this.label8.Location = new System.Drawing.Point(14, 109); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(77, 12); this.label8.TabIndex = 8; this.label8.Text = "CPU地址宽度:"; // // label9 // this.label9.AutoSize = true; this.label9.ForeColor = System.Drawing.Color.CornflowerBlue; this.label9.Location = new System.Drawing.Point(14, 129); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(77, 12); this.label9.TabIndex = 9; this.label9.Text = "CPU数据宽度:"; // // label10 // this.label10.AutoSize = true; this.label10.ForeColor = System.Drawing.Color.CornflowerBlue; this.label10.Location = new System.Drawing.Point(14, 68); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(89, 12); this.label10.TabIndex = 10; this.label10.Text = "CPU的当前电压:"; // // label11 // this.label11.AutoSize = true; this.label11.ForeColor = System.Drawing.Color.CornflowerBlue; this.label11.Location = new System.Drawing.Point(14, 89); this.label11.Name = "label11"; this.label11.Size = new System.Drawing.Size(89, 12); this.label11.TabIndex = 11; this.label11.Text = "CPU的二级缓存:"; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(396, 254); this.Controls.Add(this.label11); this.Controls.Add(this.label10); this.Controls.Add(this.label9); this.Controls.Add(this.label8); this.Controls.Add(this.label7); this.Controls.Add(this.label6); this.Controls.Add(this.label5); this.Controls.Add(this.label4); this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Controls.Add(this.button1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "Form1"; this.Text = "双核处理器浮点运算测试"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Timer timer1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label7; private System.Windows.Forms.Label label8; private System.Windows.Forms.Label label9; private System.Windows.Forms.Label label10; private System.Windows.Forms.Label label11; }}