├── h5_result.PNG
├── AccTimeBenchmark
├── Resources
│ ├── grey.png
│ └── orange.png
├── speed_128px_1151078_easyicon.net.ico
├── Properties
│ ├── Settings.settings
│ ├── PublishProfiles
│ │ └── FolderProfile.pubxml
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── app.config
├── Core
│ ├── DiskOperation.cs
│ ├── FileOperation.cs
│ └── GetUdiskList.cs
├── Program.cs
├── Scenario.cs
├── Utility
│ ├── CSVReader.cs
│ ├── SysInfo.cs
│ ├── IniFile.cs
│ └── SWOnline.cs
├── WTGBench.csproj
├── Forms
│ ├── Update.cs
│ ├── Update.designer.cs
│ ├── Update.resx
│ ├── Form1.cs
│ └── Form1.Designer.cs
└── app.manifest
├── iTuner
├── Properties
│ ├── PublishProfiles
│ │ └── FolderProfile.pubxml
│ └── AssemblyInfo.cs
├── iTuner.csproj
├── WmiExtensions.cs
├── UsbStateChange.cs
├── UsbStateChangedEventArgs.cs
├── UsbDiskCollection.cs
├── UsbDisk.cs
└── UsbManager.cs
├── README.md
├── AccTimeBenchmark.sln
├── .gitattributes
└── .gitignore
/h5_result.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nkc3g4/WTGBench/HEAD/h5_result.PNG
--------------------------------------------------------------------------------
/AccTimeBenchmark/Resources/grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nkc3g4/WTGBench/HEAD/AccTimeBenchmark/Resources/grey.png
--------------------------------------------------------------------------------
/AccTimeBenchmark/Resources/orange.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nkc3g4/WTGBench/HEAD/AccTimeBenchmark/Resources/orange.png
--------------------------------------------------------------------------------
/AccTimeBenchmark/speed_128px_1151078_easyicon.net.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nkc3g4/WTGBench/HEAD/AccTimeBenchmark/speed_128px_1151078_easyicon.net.ico
--------------------------------------------------------------------------------
/AccTimeBenchmark/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/iTuner/Properties/PublishProfiles/FolderProfile.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | Release
8 | Any CPU
9 | bin\Release\net5.0-windows\publish\
10 | FileSystem
11 |
12 |
--------------------------------------------------------------------------------
/iTuner/iTuner.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Library
5 | net6.0-windows
6 | true
7 | false
8 |
9 | iTuner
10 | iTuner
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Properties/PublishProfiles/FolderProfile.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | Release
8 | Any CPU
9 | bin\Release\net6.0-windows\publish\win-x64\
10 | FileSystem
11 | net6.0-windows
12 | win-x64
13 | true
14 | true
15 | true
16 |
17 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Core/DiskOperation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AccTimeBenchmark
9 | {
10 | class DiskOperation
11 | {
12 | public static long GetHardDiskFreeSpace(string str_HardDiskName)
13 | {
14 | long totalSize = new long();
15 | DriveInfo[] drives = DriveInfo.GetDrives();
16 | foreach (DriveInfo drive in drives)
17 | {
18 | if (drive.Name == str_HardDiskName)
19 | {
20 | totalSize = drive.TotalFreeSpace;
21 |
22 | }
23 | }
24 | return totalSize;
25 | }
26 | }
27 |
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace AccTimeBenchmark
7 | {
8 | static class Program
9 | {
10 | [System.Runtime.InteropServices.DllImport("user32.dll")]
11 | private static extern bool SetProcessDPIAware();
12 |
13 | ///
14 | /// The main entry point for the application.
15 | ///
16 | [STAThread]
17 | static void Main()
18 | {
19 | //if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();
20 |
21 | Application.EnableVisualStyles();
22 | Application.SetCompatibleTextRenderingDefault(false);
23 | Application.Run(new Form1());
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/iTuner/WmiExtensions.cs:
--------------------------------------------------------------------------------
1 | //************************************************************************************************
2 | // Copyright © 2010 Steven M. Cohn. All Rights Reserved.
3 | //
4 | //************************************************************************************************
5 |
6 | namespace iTuner
7 | {
8 | using System;
9 | using System.Management;
10 |
11 |
12 | public static class WmiExtensions
13 | {
14 |
15 | ///
16 | /// Fetch the first item from the search result collection.
17 | ///
18 | ///
19 | ///
20 |
21 | public static ManagementObject First (this ManagementObjectSearcher searcher)
22 | {
23 | ManagementObject result = null;
24 | foreach (ManagementObject item in searcher.Get())
25 | {
26 | result = item;
27 | break;
28 | }
29 | return result;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/iTuner/UsbStateChange.cs:
--------------------------------------------------------------------------------
1 | //************************************************************************************************
2 | // Copyright © 2010 Steven M. Cohn. All Rights Reserved.
3 | //
4 | //************************************************************************************************
5 |
6 | namespace iTuner
7 | {
8 | using System;
9 |
10 |
11 | ///
12 | /// Specifies the various state changes for USB disk devices.
13 | ///
14 |
15 | public enum UsbStateChange
16 | {
17 |
18 | ///
19 | /// A device has been added and is now available.
20 | ///
21 |
22 | Added,
23 |
24 |
25 | ///
26 | /// A device is about to be removed;
27 | /// allows consumers to intercept and deny the action.
28 | ///
29 |
30 | Removing,
31 |
32 |
33 | ///
34 | /// A device has been removed and is no longer available.
35 | ///
36 |
37 | Removed
38 | }
39 | }
--------------------------------------------------------------------------------
/AccTimeBenchmark/Scenario.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AccTimeBenchmark
8 | {
9 | public class Scenario
10 | {
11 | public Scenario()
12 | {
13 | TestLines = new List();
14 | }
15 | public class TestLine
16 | {
17 | public TestLine()
18 | {
19 |
20 | }
21 | public TestLine(int[] IO, float wp, float seq,int t)
22 | {
23 | IOSizes = IO;
24 | WriteProportion = wp;
25 | SeqNess = seq;
26 | Threads = t;
27 | }
28 | public int[] IOSizes { get; set; }
29 | public float WriteProportion { get; set; }
30 | public float SeqNess { get; set; }
31 | public int Threads { get; set; }
32 | }
33 | public List TestLines { get; set; }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace AccTimeBenchmark.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.6.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Utility/CSVReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AccTimeBenchmark
9 | {
10 | class CSVReader
11 | {
12 | public static Scenario Read(string fileName)
13 | {
14 | Scenario sce = new Scenario();
15 | var reader = new StreamReader(File.OpenRead(fileName));
16 |
17 | while (!reader.EndOfStream)
18 | {
19 | var line = reader.ReadLine();
20 | var values = line.Split(',');
21 | List IOSizes = new List();
22 | for(int i = 0; i < 10; i++)
23 | {
24 | int iosize = int.Parse(values[i]);
25 | if (iosize > 16777216)
26 | iosize = 16777216;
27 | IOSizes.Add(iosize);
28 | }
29 | float writeProportion = float.Parse(values[10]);
30 | float seqNess = float.Parse(values[11]);
31 | int threads = int.Parse(values[12]);
32 | if (threads > 32)
33 | threads = 32;
34 |
35 | Scenario.TestLine testLine = new Scenario.TestLine(IOSizes.ToArray(),writeProportion,seqNess, threads);
36 | sce.TestLines.Add(testLine);
37 | }
38 | return sce;
39 | }
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/iTuner/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("iTuner")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("iTuner")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("44fa4272-a10a-46ee-8258-02097400c032")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Introduction
2 | A disk performance benchmark tool.
3 |
4 | ## Test Method
5 | ### Sequential
6 | A 10-second continuous write test is conducted with a I/O size of 64MB and a maximum cumulative write of 10GB.
7 | Write speed is calculated every 64MB and the final result is averaged. This is mainly for creating test files, and the test time not enough for an accurate result.
8 |
9 | ### 4K
10 | Perform a 15 second 4K random write test. The last 7.5 seconds are doubled in weight and the lower value is doubled in weight and the average is calculated. This is closer to the performance shown by the disk in a long-term usage.
11 |
12 | ### Grade
13 | It determines weather a device is suitable for Windows To Go by testing the 4K ramdom write performance.
14 | There are five grades, Platinum, Gold, Silver, Bronze and Steel, from high to low.
15 | We recommend using Silver and above for Windows To Go. The higher the grade the better the experience.
16 |
17 | ### Scenario
18 | Scenario testing simulates the operation of the disk during daily usage, such as browsing web pages, downloading files, etc.
19 |
20 | ### Multi-threaded 4K
21 | Reflecting the performance of the disk under high pressure. Some USB disks have high single-threaded 4K performance but low multi-threaded 4K performance, resulting in a poor experience in Windows To Go.
22 |
23 | ### Full Sequential
24 | Full disk writes within the free space on the disk to determine the SLC cache size
25 |
26 | More Information(Chinese only): https://bbs.luobotou.org/forum.php?mod=viewthread&tid=11206
--------------------------------------------------------------------------------
/AccTimeBenchmark/WTGBench.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net6.0-windows
6 | true
7 | false
8 | AccTimeBenchmark
9 | WTGBench
10 | speed_128px_1151078_easyicon.net.ico
11 | 2.8.2.0
12 | 2.8.2.0
13 | app.manifest
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Designer
23 |
24 |
25 | SettingsSingleFileGenerator
26 | Settings.Designer.cs
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Utility/SysInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Management;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AccTimeBenchmark
9 | {
10 | public static class SysInfo
11 | {
12 | public static string GetCPUModel()
13 | {
14 |
15 | string CPUName = "";
16 | try
17 | {
18 | ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from Win32_Processor");//Win32_Processor
19 | foreach (ManagementObject mo in searcher.Get())
20 | {
21 | CPUName = mo["Name"].ToString();
22 | }
23 | searcher.Dispose();
24 | }
25 | catch (Exception ex) { Console.WriteLine(ex); }
26 | return CPUName;
27 |
28 | }
29 | public static string GetSysVersion()
30 | {
31 | string sysVersion = "";
32 | try
33 | {
34 | ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from win32_OperatingSystem");
35 | foreach (ManagementObject os in searcher.Get())
36 | {
37 | sysVersion = os["Caption"].ToString()+" "+os["Version"].ToString();
38 | }
39 | searcher.Dispose();
40 | }
41 | catch (Exception ex) { Console.WriteLine(ex); }
42 | return sysVersion;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("WTGBench")]
9 | [assembly: AssemblyDescription("磁盘测速工具")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("萝卜头IT论坛")]
12 | [assembly: AssemblyProduct("WTGBench")]
13 | [assembly: AssemblyCopyright("Copyright © 2022")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("75c4bdda-8a60-480b-8947-ac89cb7d1deb")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("2.9.0.0")]
36 | [assembly: AssemblyFileVersion("2.9.0.0")]
37 |
--------------------------------------------------------------------------------
/iTuner/UsbStateChangedEventArgs.cs:
--------------------------------------------------------------------------------
1 | //************************************************************************************************
2 | // Copyright © 2010 Steven M. Cohn. All Rights Reserved.
3 | //
4 | //************************************************************************************************
5 |
6 | namespace iTuner
7 | {
8 | using System;
9 |
10 |
11 | ///
12 | /// Defines the signature of an event handler method for internally handling
13 | /// USB device state changes.
14 | ///
15 | /// A description of the device state change.
16 |
17 | public delegate void UsbStateChangedEventHandler (UsbStateChangedEventArgs e);
18 |
19 |
20 | ///
21 | /// Define the arguments passed internally from the DriverWindow to the KeyManager
22 | /// handlers.
23 | ///
24 |
25 | public class UsbStateChangedEventArgs : EventArgs
26 | {
27 |
28 | ///
29 | /// Initialize a new instance with the specified state and disk.
30 | ///
31 | /// The state change code.
32 | /// The USB disk description.
33 |
34 | public UsbStateChangedEventArgs (UsbStateChange state, UsbDisk disk)
35 | {
36 | this.State = state;
37 | this.Disk = disk;
38 | }
39 |
40 |
41 | ///
42 | /// Gets the USB disk information.
43 | ///
44 |
45 | public UsbDisk Disk
46 | {
47 | get;
48 | private set;
49 | }
50 |
51 |
52 | ///
53 | /// Gets the state change code.
54 | ///
55 |
56 | public UsbStateChange State
57 | {
58 | get;
59 | private set;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/AccTimeBenchmark.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30413.136
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WTGBench", "AccTimeBenchmark\WTGBench.csproj", "{75C4BDDA-8A60-480B-8947-AC89CB7D1DEB}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iTuner", "iTuner\iTuner.csproj", "{2EBFB74E-FF39-4BB0-96F7-3AF1A99B1A15}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {75C4BDDA-8A60-480B-8947-AC89CB7D1DEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {75C4BDDA-8A60-480B-8947-AC89CB7D1DEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {75C4BDDA-8A60-480B-8947-AC89CB7D1DEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {75C4BDDA-8A60-480B-8947-AC89CB7D1DEB}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {2EBFB74E-FF39-4BB0-96F7-3AF1A99B1A15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {2EBFB74E-FF39-4BB0-96F7-3AF1A99B1A15}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {2EBFB74E-FF39-4BB0-96F7-3AF1A99B1A15}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {2EBFB74E-FF39-4BB0-96F7-3AF1A99B1A15}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {5511C503-FA68-4492-9123-A689ECA37197}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/iTuner/UsbDiskCollection.cs:
--------------------------------------------------------------------------------
1 | //************************************************************************************************
2 | // Copyright © 2010 Steven M. Cohn. All Rights Reserved.
3 | //
4 | //************************************************************************************************
5 |
6 | namespace iTuner
7 | {
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Collections.ObjectModel;
11 | using System.Linq;
12 |
13 |
14 | ///
15 | /// Maintains a collection of USB disk objects.
16 | ///
17 |
18 | public class UsbDiskCollection : ObservableCollection
19 | {
20 |
21 | ///
22 | /// Determines if the named disk is contained in this collection.
23 | ///
24 | /// The Windows name, or drive letter, of the disk to remove.
25 | ///
26 | /// True if the item is found; otherwise false.
27 | ///
28 |
29 | public bool Contains (string name)
30 | {
31 | return this.AsQueryable().Any(d => d.Name == name) == true;
32 | }
33 |
34 |
35 | ///
36 | /// Remove the named disk from the collection.
37 | ///
38 | /// The Windows name, or drive letter, of the disk to remove.
39 | ///
40 | /// True if the item is removed; otherwise false.
41 | ///
42 |
43 | public bool Remove (string name)
44 | {
45 | UsbDisk disk =
46 | (this.AsQueryable()
47 | .Where(d => d.Name == name)
48 | .Select(d => d)).FirstOrDefault();
49 |
50 | if (disk != null)
51 | {
52 | return this.Remove(disk);
53 | }
54 |
55 | return false;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Forms/Update.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Windows.Forms;
4 | //using Microsoft.Win32;
5 | namespace AccTimeBenchmark
6 |
7 | {
8 | public partial class Update : Form
9 | {
10 | string args = null;
11 | public Update(string args)
12 | {
13 | InitializeComponent();
14 | this.args = args;
15 | }
16 |
17 | private void checkBox1_CheckedChanged(object sender, EventArgs e)
18 | {
19 | if (checkBox1.Checked == true) { button1.Enabled = false; }
20 | if (checkBox1.Checked == false) { button1.Enabled = true; }
21 | }
22 |
23 | private void button2_Click(object sender, EventArgs e)
24 | {
25 | if (checkBox1.Checked == true)
26 | {
27 | IniFile.WriteVal("Main", "AutoUpdate", "0", Application.StartupPath + "\\settings.ini");
28 | //WTRegedit("nevercheckupdate", "1");
29 | }
30 | this.Close();
31 | }
32 | //private void WTRegedit(string name, string tovalue)
33 | //{
34 | // RegistryKey hklm = Registry.CurrentUser ;
35 | // RegistryKey software = hklm.OpenSubKey("SOFTWARE", true);
36 | // RegistryKey aimdir = software.CreateSubKey(Application.ProductName);
37 | // aimdir.SetValue(name, tovalue);
38 | //}
39 |
40 | private void update_Load(object sender, EventArgs e)
41 | {
42 | label1.Text += args;
43 | }
44 |
45 | private void button1_Click(object sender, EventArgs e)
46 | {
47 | Process.Start("https://bbs.luobotou.org/thread-11206-1-1.html");
48 | this.Close();
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Core/FileOperation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace AccTimeBenchmark
10 | {
11 | public static class FileOperation
12 | {
13 | public static void DeleteFolder(string dir)
14 | {
15 | if (Directory.Exists(dir))
16 | {
17 | foreach (string d in Directory.GetFileSystemEntries(dir))
18 | {
19 | if (File.Exists(d))
20 | {
21 | FileInfo fi = new FileInfo(d);
22 | if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
23 | fi.Attributes = FileAttributes.Normal;
24 |
25 | File.Delete(d);
26 | }
27 | else
28 | DeleteFolder(d);
29 | }
30 | Directory.Delete(dir, true);
31 | }
32 | }
33 | public static string GetFileVersion(string path)
34 | {
35 | try
36 | {
37 | // Get the file version for the notepad.
38 | FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(path);
39 | return myFileVersionInfo.FileVersion;
40 | // Print the file name and version number.
41 | //textBox1.Text = "File: " + myFileVersionInfo.FileDescription + '\n' +
42 | //"Version number: " + myFileVersionInfo.FileVersion;
43 | }
44 | catch (Exception ex)
45 | {
46 | return "System Version Unknown";
47 | }
48 | }
49 |
50 |
51 | public static void DeleteFile(string file)
52 | {
53 | if (File.Exists(file))
54 | {
55 | File.Delete(file);
56 | }
57 | }
58 |
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | Windows 10
43 |
44 |
45 |
46 |
47 |
48 |
52 |
59 |
60 |
61 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Core/GetUdiskList.cs:
--------------------------------------------------------------------------------
1 | using iTuner;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading;
7 | using System.Threading.Tasks;
8 | using System.Windows.Forms;
9 |
10 | namespace AccTimeBenchmark
11 | {
12 | public static class GetUdiskList
13 | {
14 | private static Thread tListUDisks;
15 | public static UsbDiskCollection diskCollection = new UsbDiskCollection();
16 |
17 | #region Udisk
18 | public delegate void OutDelegate(bool isend, object dtSource, ComboBox combobox);
19 | public static void OutText(bool isend, object dtSource, ComboBox comboBoxUd)
20 | {
21 | if (comboBoxUd.InvokeRequired)
22 | {
23 | OutDelegate outdelegate = new OutDelegate(OutText);
24 | comboBoxUd.BeginInvoke(outdelegate, new object[] { isend, dtSource, comboBoxUd });
25 | return;
26 | }
27 | comboBoxUd.DataSource = null;
28 | comboBoxUd.DataSource = dtSource;
29 |
30 | if (comboBoxUd.Items.Count != 0)
31 | {
32 | comboBoxUd.SelectedIndex = 0;
33 | }
34 | if (isend)
35 | {
36 | comboBoxUd.SelectedIndex = comboBoxUd.Items.Count - 1;
37 | }
38 | }
39 |
40 | private static UsbDiskCollection GetUsbDiskCollection()
41 | {
42 | UsbManager manager = new UsbManager();
43 |
44 | UsbDiskCollection usbDisks = new UsbDiskCollection();
45 | try
46 | {
47 |
48 | foreach (UsbDisk disk in manager.GetAvailableVolumns())
49 | {
50 | usbDisks.Add(disk);
51 | }
52 | }
53 | catch (Exception ex) {
54 | }
55 | return usbDisks;
56 | }
57 | public static void GetUdiskInfo()
58 | {
59 |
60 | UsbManager manager = new UsbManager();
61 | try
62 | {
63 | var newDiskCollection = GetUsbDiskCollection();
64 | if (!diskCollection.SequenceEqual(newDiskCollection))
65 | {
66 | diskCollection = newDiskCollection;
67 | OutText(false, diskCollection, cbb);
68 | }
69 | }
70 | catch (Exception ex) { }
71 | finally
72 | {
73 | manager.Dispose();
74 | }
75 |
76 | }
77 |
78 | public static void LoadUDList(ComboBox comboBoxUd)
79 | {
80 | cbb = comboBoxUd;
81 | GetUdiskInfo();
82 | //Udlist = new Udlist();
83 | System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
84 | timer1.Enabled = true;
85 | timer1.Tick += timer1_Tick;
86 | timer1.Interval = 2000;
87 | timer1.Start();
88 | }
89 | static ComboBox cbb = null;
90 | private static void timer1_Tick(object sender, EventArgs e)
91 | {
92 | if (cbb.SelectedIndex == 0)
93 | {
94 | tListUDisks = new Thread(GetUdiskInfo);
95 | tListUDisks.Start();
96 | }
97 | }
98 | #endregion
99 | }
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace AccTimeBenchmark.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AccTimeBenchmark.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Drawing.Bitmap.
65 | ///
66 | internal static System.Drawing.Bitmap grey {
67 | get {
68 | object obj = ResourceManager.GetObject("grey", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Looks up a localized resource of type System.Drawing.Bitmap.
75 | ///
76 | internal static System.Drawing.Bitmap orange {
77 | get {
78 | object obj = ResourceManager.GetObject("orange", resourceCulture);
79 | return ((System.Drawing.Bitmap)(obj));
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Utility/IniFile.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Forms;
8 |
9 | namespace AccTimeBenchmark
10 | {
11 | class IniFile
12 | {
13 | //绝对路径(默认执行程序目录)
14 | public string FilePath { get; set; }
15 |
16 | ///
17 | /// 读取ini文件
18 | ///
19 | /// 段落名
20 | /// 键
21 | /// 缺省值
22 | /// 所对应的值,如果该key不存在则返回空值
23 | /// 值允许的大小
24 | /// INI文件的完整路径和文件名
25 | ///
26 | [DllImport("kernel32")]
27 | private static extern int GetPrivateProfileString(
28 | string section, string key, string defVal,
29 | StringBuilder retVal, int size, string filePath);
30 |
31 | ///
32 | /// 写入ini文件
33 | ///
34 | /// 段落名
35 | /// 键
36 | /// 值
37 | /// INI文件的完整路径和文件名
38 | ///
39 | [DllImport("kernel32")]
40 | private static extern long WritePrivateProfileString(
41 | string section, string key, string val, string filePath);
42 |
43 | #region 静态方法
44 |
45 | public static string ReadVal(string section, string key, string filePath)
46 | {
47 | string defVal = string.Empty;
48 | StringBuilder retVal = new StringBuilder(260);
49 | int size = 102400;
50 | string rt = string.Empty;
51 | try
52 | {
53 | GetPrivateProfileString(section, key, defVal, retVal, size, filePath);
54 | rt = retVal.ToString();
55 | }
56 | catch (Exception ex)
57 | {
58 | MessageBox.Show(ex.ToString());
59 |
60 | rt = string.Empty;
61 | }
62 | return rt;
63 | }
64 |
65 | public static bool WriteVal(string section, string key, string val, string filePath)
66 | {
67 | try
68 | {
69 | if (WritePrivateProfileString(section, key, val, filePath) == 0)
70 | return false;
71 | else
72 | return true;
73 | }
74 | catch
75 | {
76 | return false;
77 | }
78 | }
79 |
80 | #endregion
81 |
82 | #region 对象方法
83 |
84 | public string ReadVal(string section, string key)
85 | {
86 | string defVal = string.Empty;
87 | StringBuilder retVal = new StringBuilder();
88 | int size = 10240;
89 | string rt = string.Empty;
90 | try
91 | {
92 | GetPrivateProfileString(section, key,
93 | defVal, retVal, size, this.FilePath);
94 | rt = retVal.ToString();
95 | }
96 | catch
97 | {
98 | rt = string.Empty;
99 | }
100 | return rt;
101 | }
102 |
103 | public bool WriteVal(string section, string key, string val)
104 | {
105 | try
106 | {
107 | WritePrivateProfileString(section, key, val, this.FilePath);
108 | return true;
109 | }
110 | catch
111 | {
112 | return false;
113 | }
114 | }
115 |
116 | #endregion
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Forms/Update.designer.cs:
--------------------------------------------------------------------------------
1 | namespace AccTimeBenchmark
2 | {
3 | partial class Update
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Update));
32 | this.label1 = new System.Windows.Forms.Label();
33 | this.label2 = new System.Windows.Forms.Label();
34 | this.button1 = new System.Windows.Forms.Button();
35 | this.button2 = new System.Windows.Forms.Button();
36 | this.checkBox1 = new System.Windows.Forms.CheckBox();
37 | this.SuspendLayout();
38 | //
39 | // label1
40 | //
41 | resources.ApplyResources(this.label1, "label1");
42 | this.label1.Name = "label1";
43 | //
44 | // label2
45 | //
46 | resources.ApplyResources(this.label2, "label2");
47 | this.label2.Name = "label2";
48 | //
49 | // button1
50 | //
51 | resources.ApplyResources(this.button1, "button1");
52 | this.button1.Name = "button1";
53 | this.button1.UseVisualStyleBackColor = true;
54 | this.button1.Click += new System.EventHandler(this.button1_Click);
55 | //
56 | // button2
57 | //
58 | resources.ApplyResources(this.button2, "button2");
59 | this.button2.Name = "button2";
60 | this.button2.UseVisualStyleBackColor = true;
61 | this.button2.Click += new System.EventHandler(this.button2_Click);
62 | //
63 | // checkBox1
64 | //
65 | resources.ApplyResources(this.checkBox1, "checkBox1");
66 | this.checkBox1.Name = "checkBox1";
67 | this.checkBox1.UseVisualStyleBackColor = true;
68 | this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
69 | //
70 | // Update
71 | //
72 | resources.ApplyResources(this, "$this");
73 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
74 | this.Controls.Add(this.checkBox1);
75 | this.Controls.Add(this.button2);
76 | this.Controls.Add(this.button1);
77 | this.Controls.Add(this.label2);
78 | this.Controls.Add(this.label1);
79 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
80 | //this.Icon = global::AccTimeBenchmark.Properties.Resources.;
81 | this.MaximizeBox = false;
82 | this.MinimizeBox = false;
83 | this.Name = "Update";
84 | this.Load += new System.EventHandler(this.update_Load);
85 | this.ResumeLayout(false);
86 | this.PerformLayout();
87 |
88 | }
89 |
90 | #endregion
91 |
92 | private System.Windows.Forms.Label label1;
93 | private System.Windows.Forms.Label label2;
94 | private System.Windows.Forms.Button button1;
95 | private System.Windows.Forms.Button button2;
96 | private System.Windows.Forms.CheckBox checkBox1;
97 | }
98 | }
--------------------------------------------------------------------------------
/AccTimeBenchmark/Utility/SWOnline.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Text;
6 | using System.Text.RegularExpressions;
7 | using System.Threading.Tasks;
8 | using System.Windows.Forms;
9 |
10 | namespace AccTimeBenchmark
11 | {
12 |
13 | public class SWOnline
14 | {
15 |
16 | public SWOnline()
17 | {
18 |
19 |
20 | }
21 | public SWOnline(string releaseUrl)
22 | {
23 | ReleaseUrl = releaseUrl;
24 | }
25 |
26 | public string ReleaseUrl { get; set; }
27 |
28 | public string[] TopicLink { get; set; }
29 |
30 | public string[] TopicName { get; set; }
31 |
32 | public LinkLabel Linklabel { get; set; }
33 | public void Update()
34 | {
35 | string autoup = IniFile.ReadVal("Main", "AutoUpdate", Application.StartupPath + "\\settings.ini");
36 | if (autoup == "0") { return; }
37 | string pageHtml;
38 | try
39 | {
40 | WebClient MyWebClient = new WebClient();
41 | //MyWebClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
42 | MyWebClient.Credentials = CredentialCache.DefaultCredentials;
43 | byte[] pageData = MyWebClient.DownloadData(ReleaseUrl); //从指定网站下载数据"https://bbs.luobotou.org/app/wintogo.txt"
44 |
45 | pageHtml = Encoding.UTF8.GetString(pageData);
46 | int index = pageHtml.IndexOf("~");
47 | Version newVer = new Version(pageHtml.Substring(index + 1, 7));
48 | Version currentVer = new Version(Application.ProductVersion);
49 |
50 | if (newVer > currentVer)
51 | {
52 | Update frmf = new Update(newVer.ToString());
53 | frmf.ShowDialog();
54 | }
55 |
56 | }
57 | catch (WebException webEx)
58 | {
59 | Console.WriteLine(webEx);
60 | //Log.WriteLog("Err_UpdateErr", webEx.ToString());
61 | }
62 | }
63 | public void Showad()
64 | {
65 | string pageHtml;
66 | try
67 | {
68 | WebClient MyWebClient = new WebClient();
69 |
70 | MyWebClient.Credentials = CredentialCache.DefaultCredentials;
71 |
72 | byte[] pageData = MyWebClient.DownloadData(ReleaseUrl); //从指定网站下载数据
73 | //MyWebClient.DownloadString()
74 | pageHtml = Encoding.UTF8.GetString(pageData);
75 | int index = pageHtml.IndexOf("announcement=");
76 | int indexbbs = pageHtml.IndexOf("bbs=");
77 | if (pageHtml.Substring(index + 13, 1) != "0")
78 | {
79 | if (pageHtml.Substring(indexbbs + 4, 1) == "1")
80 | {
81 | MyWebClient.Credentials = CredentialCache.DefaultCredentials;
82 | byte[] pageData1 = MyWebClient.DownloadData("https://bbs.luobotou.org/portal.php");
83 | pageHtml = Encoding.UTF8.GetString(pageData1);
84 |
85 | #region 正则表达式实现
86 |
87 | Match matchArticles = Regex.Match(pageHtml, @"");
88 | MatchCollection matches = Regex.Matches(matchArticles.Groups[0].Value, @"(.+?)");
89 |
90 | for (int i = 0; i < matches.Count; i++)
91 | {
92 | TopicLink[i] = matches[i].Groups[1].Value;
93 | TopicName[i] = matches[i].Groups[2].Value;
94 | //Console.WriteLine(TopicName[i]);
95 |
96 | }
97 | #endregion
98 |
99 | }
100 | pageHtml = MyWebClient.DownloadString("https://bbs.luobotou.org/app/announcement.txt");
101 | Match match = Regex.Match(pageHtml, Application.ProductName + "=(.+)~(.+)结束");
102 | string adlink = match.Groups[2].Value;
103 | string adtitle = match.Groups[1].Value;
104 | Linklabel.Invoke(new Action(() =>
105 | {
106 | Linklabel.Text = adtitle;
107 | Linklabel.Visible = true;
108 | }));
109 | Linklabel.Tag = adlink;
110 | }
111 | }
112 | catch (Exception ex)
113 | {
114 | Console.WriteLine(ex);
115 | //Log.WriteLog("Err_ShowAdError", ex.ToString());
116 | }
117 | }
118 |
119 |
120 |
121 |
122 | }
123 |
124 |
125 | }
126 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # NCrunch
114 | _NCrunch_*
115 | .*crunch*.local.xml
116 | nCrunchTemp_*
117 |
118 | # MightyMoose
119 | *.mm.*
120 | AutoTest.Net/
121 |
122 | # Web workbench (sass)
123 | .sass-cache/
124 |
125 | # Installshield output folder
126 | [Ee]xpress/
127 |
128 | # DocProject is a documentation generator add-in
129 | DocProject/buildhelp/
130 | DocProject/Help/*.HxT
131 | DocProject/Help/*.HxC
132 | DocProject/Help/*.hhc
133 | DocProject/Help/*.hhk
134 | DocProject/Help/*.hhp
135 | DocProject/Help/Html2
136 | DocProject/Help/html
137 |
138 | # Click-Once directory
139 | publish/
140 |
141 | # Publish Web Output
142 | *.[Pp]ublish.xml
143 | *.azurePubxml
144 | # TODO: Comment the next line if you want to checkin your web deploy settings
145 | # but database connection strings (with potential passwords) will be unencrypted
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
150 | # checkin your Azure Web App publish settings, but sensitive information contained
151 | # in these scripts will be unencrypted
152 | PublishScripts/
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 | # NuGet v3's project.json files produces more ignoreable files
163 | *.nuget.props
164 | *.nuget.targets
165 |
166 | # Microsoft Azure Build Output
167 | csx/
168 | *.build.csdef
169 |
170 | # Microsoft Azure Emulator
171 | ecf/
172 | rcf/
173 |
174 | # Windows Store app package directories and files
175 | AppPackages/
176 | BundleArtifacts/
177 | Package.StoreAssociation.xml
178 | _pkginfo.txt
179 |
180 | # Visual Studio cache files
181 | # files ending in .cache can be ignored
182 | *.[Cc]ache
183 | # but keep track of directories ending in .cache
184 | !*.[Cc]ache/
185 |
186 | # Others
187 | ClientBin/
188 | ~$*
189 | *~
190 | *.dbmdl
191 | *.dbproj.schemaview
192 | *.jfm
193 | *.pfx
194 | *.publishsettings
195 | node_modules/
196 | orleans.codegen.cs
197 |
198 | # Since there are multiple workflows, uncomment next line to ignore bower_components
199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200 | #bower_components/
201 |
202 | # RIA/Silverlight projects
203 | Generated_Code/
204 |
205 | # Backup & report files from converting an old project file
206 | # to a newer Visual Studio version. Backup files are not needed,
207 | # because we have git ;-)
208 | _UpgradeReport_Files/
209 | Backup*/
210 | UpgradeLog*.XML
211 | UpgradeLog*.htm
212 |
213 | # SQL Server files
214 | *.mdf
215 | *.ldf
216 |
217 | # Business Intelligence projects
218 | *.rdl.data
219 | *.bim.layout
220 | *.bim_*.settings
221 |
222 | # Microsoft Fakes
223 | FakesAssemblies/
224 |
225 | # GhostDoc plugin setting file
226 | *.GhostDoc.xml
227 |
228 | # Node.js Tools for Visual Studio
229 | .ntvs_analysis.dat
230 |
231 | # Visual Studio 6 build log
232 | *.plg
233 |
234 | # Visual Studio 6 workspace options file
235 | *.opt
236 |
237 | # Visual Studio LightSwitch build output
238 | **/*.HTMLClient/GeneratedArtifacts
239 | **/*.DesktopClient/GeneratedArtifacts
240 | **/*.DesktopClient/ModelManifest.xml
241 | **/*.Server/GeneratedArtifacts
242 | **/*.Server/ModelManifest.xml
243 | _Pvt_Extensions
244 |
245 | # Paket dependency manager
246 | .paket/paket.exe
247 | paket-files/
248 |
249 | # FAKE - F# Make
250 | .fake/
251 |
252 | # JetBrains Rider
253 | .idea/
254 | *.sln.iml
255 |
256 | # CodeRush
257 | .cr/
258 |
259 | # Python Tools for Visual Studio (PTVS)
260 | __pycache__/
261 | *.pyc
--------------------------------------------------------------------------------
/iTuner/UsbDisk.cs:
--------------------------------------------------------------------------------
1 | //************************************************************************************************
2 | // Copyright © 2010 Steven M. Cohn. All Rights Reserved.
3 | //
4 | //************************************************************************************************
5 |
6 | namespace iTuner
7 | {
8 | using System;
9 | using System.Text;
10 |
11 |
12 | ///
13 | /// Represents the displayable information for a single USB disk.
14 | ///
15 |
16 | public class UsbDisk:IEquatable
17 | {
18 | private const int KB = 1024;
19 | private const int MB = KB * 1024;
20 | private const int GB = MB * 1024;
21 |
22 |
23 | ///
24 | /// Initialize a new instance with the given values.
25 | ///
26 | /// The Windows drive letter assigned to this device.
27 |
28 | public UsbDisk(string name)
29 | {
30 | this.Name = name;
31 | this.Model = String.Empty;
32 | Volume = String.Empty;
33 | Index = String.Empty;
34 | this.VolumeName = String.Empty;
35 | this.FreeSpace = 0;
36 | this.Size = 0;
37 | this.DriveType = String.Empty;
38 | }
39 |
40 |
41 | ///
42 | /// Gets the available free space on the disk, specified in bytes.
43 | ///
44 |
45 | public ulong FreeSpace
46 | {
47 | get;
48 | internal set;
49 | }
50 |
51 | public string DriveType
52 | {
53 | get;
54 | internal set;
55 | }
56 | ///
57 | /// Get the model of this disk. This is the manufacturer's name.
58 | ///
59 | ///
60 | /// When this class is used to identify a removed USB device, the Model
61 | /// property is set to String.Empty.
62 | ///
63 |
64 | public string Model
65 | {
66 | get;
67 | internal set;
68 | }
69 |
70 |
71 | ///
72 | /// Gets the name of this disk. This is the Windows identifier, drive letter.
73 | ///
74 |
75 | public string Name
76 | {
77 | get;
78 | private set;
79 | }
80 |
81 |
82 | ///
83 | /// Gets the total size of the volume, specified in bytes.
84 | ///
85 |
86 | public ulong Size
87 | {
88 | get;
89 | internal set;
90 | }
91 |
92 | ///
93 | /// Gets the total size of the disk, specified in bytes.
94 | ///
95 |
96 | public ulong DiskSize
97 | {
98 | get;
99 | internal set;
100 | }
101 | ///
102 | /// Get the volume name of this disk. This is the friently name ("Stick").
103 | ///
104 | ///
105 | /// When this class is used to identify a removed USB device, the Volume
106 | /// property is set to String.Empty.
107 | ///
108 | public string Index
109 | {
110 | get;
111 | internal set;
112 | }
113 | public string Volume
114 | {
115 | get;
116 | internal set;
117 | }
118 | public string FileSystem
119 | {
120 | get;
121 | internal set;
122 | }
123 | public string VolumeName
124 | {
125 | get;
126 | internal set;
127 | }
128 | public ulong TotalSectors
129 | {
130 | get;
131 | internal set;
132 | }
133 |
134 | ///
135 | /// Pretty print the disk.
136 | ///
137 | ///
138 |
139 | public override string ToString()
140 | {
141 |
142 | //System.Windows.Forms.MessageBox.Show(this.Model); System.Windows.Forms.MessageBox.Show("Test");
143 | if (this.Model == string.Empty)
144 | {
145 | //System.Windows.Forms.MessageBox.Show(this.Name);
146 | return this.Name;
147 | }
148 | else
149 | {
150 | StringBuilder builder = new StringBuilder();
151 | builder.Append(Volume);
152 | builder.Append(" ");
153 | builder.Append(" (");
154 | builder.Append(FileSystem);
155 | builder.Append(") ");
156 | builder.Append(Model);
157 | builder.Append(" ");
158 | builder.Append(FormatByteCount(Size));
159 | builder.Append(" (");
160 | builder.Append(DriveType);
161 | builder.Append(") ");
162 | return builder.ToString();
163 | }
164 | }
165 | public void SetVolume(string volume)
166 | {
167 | Volume = volume;
168 | }
169 |
170 |
171 | private string FormatByteCount(ulong bytes)
172 | {
173 | string format = null;
174 |
175 | if (bytes < KB)
176 | {
177 | format = String.Format("{0} Bytes", bytes);
178 | }
179 | else if (bytes < MB)
180 | {
181 | bytes = bytes / KB;
182 | format = String.Format("{0} KB", bytes.ToString("N"));
183 | }
184 | else if (bytes < GB)
185 | {
186 | double dree = bytes / MB;
187 | format = String.Format("{0} MB", dree.ToString("N1"));
188 | }
189 | else
190 | {
191 | double gree = bytes / GB;
192 | format = String.Format("{0} GB", gree.ToString("N1"));
193 | }
194 |
195 | return format;
196 | }
197 |
198 | public bool Equals(UsbDisk other)
199 | {
200 | if (other is null)
201 | return false;
202 |
203 | return ToString() == other.ToString();
204 | }
205 | public override bool Equals(object obj) => Equals(obj as UsbDisk);
206 | public override int GetHashCode() => ToString().GetHashCode();
207 |
208 | }
209 | }
210 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\orange.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\Resources\grey.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Forms/Update.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | True
123 |
124 |
125 |
126 | Microsoft YaHei, 9pt
127 |
128 |
129 | 12, 9
130 |
131 |
132 | 72, 17
133 |
134 |
135 | 0
136 |
137 |
138 | 发现新版本
139 |
140 |
141 | label1
142 |
143 |
144 | System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
145 |
146 |
147 | $this
148 |
149 |
150 | 4
151 |
152 |
153 | True
154 |
155 |
156 | Microsoft YaHei, 9pt
157 |
158 |
159 | 134, 9
160 |
161 |
162 | 68, 17
163 |
164 |
165 | 1
166 |
167 |
168 | 是否更新?
169 |
170 |
171 | label2
172 |
173 |
174 | System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
175 |
176 |
177 | $this
178 |
179 |
180 | 3
181 |
182 |
183 | Microsoft YaHei, 9pt
184 |
185 |
186 | 12, 61
187 |
188 |
189 | 75, 23
190 |
191 |
192 | 2
193 |
194 |
195 | 现在更新
196 |
197 |
198 | button1
199 |
200 |
201 | System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
202 |
203 |
204 | $this
205 |
206 |
207 | 2
208 |
209 |
210 | Microsoft YaHei, 9pt
211 |
212 |
213 | 127, 61
214 |
215 |
216 | 75, 23
217 |
218 |
219 | 3
220 |
221 |
222 | 以后再说
223 |
224 |
225 | button2
226 |
227 |
228 | System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
229 |
230 |
231 | $this
232 |
233 |
234 | 1
235 |
236 |
237 | True
238 |
239 |
240 | Microsoft YaHei, 9pt
241 |
242 |
243 | 15, 38
244 |
245 |
246 | 111, 21
247 |
248 |
249 | 4
250 |
251 |
252 | 不再提示此更新
253 |
254 |
255 | checkBox1
256 |
257 |
258 | System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
259 |
260 |
261 | $this
262 |
263 |
264 | 0
265 |
266 |
267 | True
268 |
269 |
270 | 6, 13
271 |
272 |
273 | 214, 94
274 |
275 |
276 |
277 | CenterScreen
278 |
279 |
280 | 新版本提示
281 |
282 |
283 | Update
284 |
285 |
286 | System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
287 |
288 |
--------------------------------------------------------------------------------
/iTuner/UsbManager.cs:
--------------------------------------------------------------------------------
1 | //************************************************************************************************
2 | // Copyright © 2010 Steven M. Cohn. All Rights Reserved.
3 | //
4 | //************************************************************************************************
5 |
6 | namespace iTuner
7 | {
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Management;
11 | using System.Runtime.InteropServices;
12 | using System.Windows.Forms;
13 |
14 |
15 | ///
16 | /// Discover USB disk devices and monitor for device state changes.
17 | ///
18 |
19 | public class UsbManager : IDisposable
20 | {
21 |
22 | #region DriverWindow
23 |
24 | ///
25 | /// A native window used to monitor all device activity.
26 | ///
27 |
28 | private class DriverWindow : NativeWindow, IDisposable
29 | {
30 | // Contains information about a logical volume.
31 | [StructLayout(LayoutKind.Sequential)]
32 | public struct DEV_BROADCAST_VOLUME
33 | {
34 | public int dbcv_size; // size of the struct
35 | public int dbcv_devicetype; // DBT_DEVTYP_VOLUME
36 | public int dbcv_reserved; // reserved; do not use
37 | public int dbcv_unitmask; // Bit 0=A, bit 1=B, and so on (bitmask)
38 | public short dbcv_flags; // DBTF_MEDIA=0x01, DBTF_NET=0x02 (bitmask)
39 | }
40 |
41 |
42 | private const int WM_DEVICECHANGE = 0x0219; // device state change
43 | private const int DBT_DEVICEARRIVAL = 0x8000; // detected a new device
44 | private const int DBT_DEVICEQUERYREMOVE = 0x8001; // preparing to remove
45 | private const int DBT_DEVICEREMOVECOMPLETE = 0x8004; // removed
46 | private const int DBT_DEVTYP_VOLUME = 0x00000002; // logical volume
47 |
48 |
49 | public DriverWindow()
50 | {
51 | // create a generic window with no class name
52 | base.CreateHandle(new CreateParams());
53 | }
54 |
55 |
56 | public void Dispose()
57 | {
58 | base.DestroyHandle();
59 | GC.SuppressFinalize(this);
60 | }
61 |
62 |
63 | public event UsbStateChangedEventHandler StateChanged;
64 |
65 |
66 | protected override void WndProc(ref Message message)
67 | {
68 | base.WndProc(ref message);
69 |
70 | if ((message.Msg == WM_DEVICECHANGE) && (message.LParam != IntPtr.Zero))
71 | {
72 | DEV_BROADCAST_VOLUME volume = (DEV_BROADCAST_VOLUME)Marshal.PtrToStructure(
73 | message.LParam, typeof(DEV_BROADCAST_VOLUME));
74 |
75 | if (volume.dbcv_devicetype == DBT_DEVTYP_VOLUME)
76 | {
77 | switch (message.WParam.ToInt32())
78 | {
79 | case DBT_DEVICEARRIVAL:
80 | SignalDeviceChange(UsbStateChange.Added, volume);
81 | break;
82 |
83 | case DBT_DEVICEQUERYREMOVE:
84 | // can intercept
85 | break;
86 |
87 | case DBT_DEVICEREMOVECOMPLETE:
88 | SignalDeviceChange(UsbStateChange.Removed, volume);
89 | break;
90 | }
91 | }
92 | }
93 | }
94 |
95 |
96 | private void SignalDeviceChange(UsbStateChange state, DEV_BROADCAST_VOLUME volume)
97 | {
98 | string name = ToUnitName(volume.dbcv_unitmask);
99 |
100 | if (StateChanged != null)
101 | {
102 | UsbDisk disk = new UsbDisk(name);
103 | StateChanged(new UsbStateChangedEventArgs(state, disk));
104 | }
105 | }
106 |
107 |
108 | ///
109 | /// Translate the dbcv_unitmask bitmask to a drive letter by finding the first
110 | /// enabled low-order bit; its offset equals the letter where offset 0 is 'A'.
111 | ///
112 | ///
113 | ///
114 |
115 | private string ToUnitName(int mask)
116 | {
117 | int offset = 0;
118 | while ((offset < 26) && ((mask & 0x00000001) == 0))
119 | {
120 | mask = mask >> 1;
121 | offset++;
122 | }
123 |
124 | if (offset < 26)
125 | {
126 | return String.Format("{0}:", Convert.ToChar(Convert.ToInt32('A') + offset));
127 | }
128 |
129 | return "?:";
130 | }
131 | }
132 |
133 | #endregion WndProc Driver
134 |
135 |
136 | private delegate void GetDiskInformationDelegate(UsbDisk disk);
137 |
138 |
139 | private DriverWindow window;
140 | private UsbStateChangedEventHandler handler;
141 | private bool isDisposed;
142 |
143 |
144 | //========================================================================================
145 | // Constructor
146 | //========================================================================================
147 |
148 | ///
149 | /// Initialize a new instance.
150 | ///
151 |
152 | public UsbManager()
153 | {
154 | this.window = null;
155 | this.handler = null;
156 | this.isDisposed = false;
157 | }
158 |
159 |
160 | #region Lifecycle
161 |
162 | ///
163 | /// Destructor.
164 | ///
165 |
166 | ~UsbManager()
167 | {
168 | Dispose();
169 | }
170 |
171 |
172 | ///
173 | /// Must shutdown the driver window.
174 | ///
175 |
176 | public void Dispose()
177 | {
178 | if (!isDisposed)
179 | {
180 | if (window != null)
181 | {
182 | window.StateChanged -= new UsbStateChangedEventHandler(DoStateChanged);
183 | window.Dispose();
184 | window = null;
185 | }
186 |
187 | isDisposed = true;
188 |
189 | GC.SuppressFinalize(this);
190 | }
191 | }
192 |
193 | #endregion Lifecycle
194 |
195 |
196 | //========================================================================================
197 | // Events/Properties
198 | //========================================================================================
199 |
200 | ///
201 | /// Add or remove a handler to listen for USB disk drive state changes.
202 | ///
203 |
204 | public event UsbStateChangedEventHandler StateChanged
205 | {
206 | add
207 | {
208 | if (window == null)
209 | {
210 | // create the driver window once a consumer registers for notifications
211 | window = new DriverWindow();
212 | window.StateChanged += new UsbStateChangedEventHandler(DoStateChanged);
213 | }
214 |
215 | handler = (UsbStateChangedEventHandler)Delegate.Combine(handler, value);
216 | }
217 |
218 | remove
219 | {
220 | handler = (UsbStateChangedEventHandler)Delegate.Remove(handler, value);
221 |
222 | if (handler == null)
223 | {
224 | // destroy the driver window once the consumer stops listening
225 | window.StateChanged -= new UsbStateChangedEventHandler(DoStateChanged);
226 | window.Dispose();
227 | window = null;
228 | }
229 | }
230 | }
231 |
232 |
233 | //========================================================================================
234 | // Methods
235 | //========================================================================================
236 |
237 |
238 | ///
239 | /// Gets a collection of all available USB disk drives currently mounted.
240 | ///
241 | ///
242 | /// A UsbDiskCollection containing the USB disk drives.
243 | ///
244 |
245 | public UsbDiskCollection GetAvailableVolumns()
246 | {
247 | UsbDiskCollection volumns = new UsbDiskCollection();
248 |
249 | // browse all USB WMI physical disks
250 | foreach (ManagementObject drive in
251 | new ManagementObjectSearcher(
252 | "select DeviceID,Model,Size,Index,MediaType,Size,InterfaceType from Win32_DiskDrive").Get())
253 | {
254 | try
255 | {
256 | //if ((uint)drive["Index"] < 1) continue;
257 | //if (drive["InterfaceType"].ToString() != "USB" && drive["InterfaceType"].ToString() != "SCSI") continue;
258 | if (drive["Model"].ToString().Contains("APPLE SD")) continue;
259 | UsbDisk disk = new UsbDisk(drive["DeviceID"].ToString());
260 |
261 | disk.Model = drive["Model"].ToString();
262 | disk.Index = drive["Index"].ToString();
263 | disk.DiskSize = (ulong)drive["Size"];
264 | disk.DriveType = drive["MediaType"].ToString();
265 | disk.Size = (ulong)drive["Size"];
266 | // associate physical disks with partitions
267 | foreach (ManagementObject partition in new ManagementObjectSearcher(string.Format(
268 | "associators of {{Win32_DiskDrive.DeviceID='{0}'}} where AssocClass = Win32_DiskDriveToDiskPartition",
269 | drive["DeviceID"])).Get())
270 | {
271 | try
272 | {
273 | if (partition != null)
274 | {
275 | // associate partitions with logical disks (drive letter volumes)
276 | ManagementObject logical = new ManagementObjectSearcher(string.Format(
277 | "associators of {{Win32_DiskPartition.DeviceID='{0}'}} where AssocClass = Win32_LogicalDiskToPartition",
278 | partition["DeviceID"])).First();
279 | if (logical != null)
280 | {
281 | // finally find the logical disk entry to determine the volume name
282 | ManagementObject volume = new ManagementObjectSearcher(string.Format(
283 | "select FreeSpace, Size, VolumeName, DriveType, FileSystem from Win32_LogicalDisk where Name='{0}'",
284 | logical["Name"])).First();
285 |
286 | UsbDisk diskVolume = new UsbDisk(drive["DeviceID"].ToString());
287 | diskVolume.Model = drive["Model"].ToString();
288 | diskVolume.Index = drive["Index"].ToString();
289 | diskVolume.Volume = logical["Name"].ToString();
290 | diskVolume.FileSystem = volume["FileSystem"].ToString();
291 | diskVolume.DiskSize = (ulong)drive["Size"];
292 | diskVolume.DriveType = drive["MediaType"].ToString();
293 | diskVolume.Size = (ulong)volume["Size"];
294 | //diskVolume.DiskSize = (ulong)volume["Size"];
295 | diskVolume.FreeSpace = (ulong)volume["FreeSpace"];
296 | volumns.Add(diskVolume);
297 | }
298 | }
299 | }
300 | catch (Exception ex)
301 | {
302 | Console.WriteLine(ex.ToString());
303 | //disks.Add(new UsbDisk(ex.ToString()));
304 | }
305 | }
306 | //if (!hasAdded) disks.Add(disk);
307 | }
308 | catch (Exception e)
309 | {
310 | Console.WriteLine(e.ToString());
311 | //MessageBox.Show(e.ToString());
312 | }
313 | }
314 |
315 | return volumns;
316 | }
317 |
318 |
319 | ///
320 | /// Internally handle state changes and notify listeners.
321 | ///
322 | ///
323 |
324 | private void DoStateChanged(UsbStateChangedEventArgs e)
325 | {
326 | if (handler != null)
327 | {
328 | UsbDisk disk = e.Disk;
329 |
330 | // we can only interrogate drives that are added...
331 | // cannot see something that is no longer there!
332 |
333 | if ((e.State == UsbStateChange.Added) && (e.Disk.Name[0] != '?'))
334 | {
335 | // the following Begin/End invokes looks strange but are required
336 | // to resolve a "DisconnectedContext was detected" exception which
337 | // occurs when the current thread terminates before the WMI queries
338 | // can complete. I'm not exactly sure why that would happen...
339 |
340 | GetDiskInformationDelegate gdi = new GetDiskInformationDelegate(GetDiskInformation);
341 | IAsyncResult result = gdi.BeginInvoke(e.Disk, null, null);
342 | gdi.EndInvoke(result);
343 | }
344 |
345 | handler(e);
346 | }
347 | }
348 |
349 |
350 | ///
351 | /// Populate the missing properties of the given disk before sending to listeners
352 | ///
353 | ///
354 |
355 | private void GetDiskInformation(UsbDisk disk)
356 | {
357 | ManagementObject partition = new ManagementObjectSearcher(String.Format(
358 | "associators of {{Win32_LogicalDisk.DeviceID='{0}'}} where AssocClass = Win32_LogicalDiskToPartition",
359 | disk.Name)).First();
360 |
361 | if (partition != null)
362 | {
363 | ManagementObject drive = new ManagementObjectSearcher(String.Format(
364 | "associators of {{Win32_DiskPartition.DeviceID='{0}'}} where resultClass = Win32_DiskDrive",
365 | partition["DeviceID"])).First();
366 | //MessageBox.Show(drive.ToString());
367 |
368 | if (drive != null)
369 | {
370 | disk.Model = drive["Model"].ToString();
371 | }
372 |
373 | ManagementObject volume = new ManagementObjectSearcher(String.Format(
374 | "select FreeSpace, Size, VolumeName from Win32_LogicalDisk where Name='{0}'",
375 | disk.Name)).First();
376 |
377 | if (volume != null)
378 | {
379 | disk.VolumeName = volume["VolumeName"].ToString();
380 | disk.FreeSpace = (ulong)volume["FreeSpace"];
381 | disk.Size = (ulong)volume["Size"];
382 | disk.DriveType = Drivetypeconvert(Int32.Parse(volume["DriveType"].ToString()));
383 | //MessageBox.Show(disk.DriveType);
384 | }
385 | }
386 | }
387 | private string Drivetypeconvert(int code)
388 | {
389 | switch (code)
390 | {
391 | case 0:
392 | return "Unknown";
393 | case 1:
394 | return "No Root Directory";
395 | case 2:
396 | return "Removable Disk";
397 | case 3:
398 | return "Local Disk";
399 | case 4:
400 | return "Network Drive";
401 | case 5:
402 | return "Compact Disc";
403 | case 6:
404 | return "RAM Disk";
405 | default:
406 | return "Type Error";
407 | }
408 | }
409 | }
410 | public class USBAudioDeviceItems : Dictionary
411 | {
412 | protected USBAudioDeviceItems()
413 | {
414 |
415 | }
416 | protected USBAudioDeviceItems(IDictionary dictionary)
417 | : base(dictionary)
418 | {
419 |
420 | }
421 | private readonly static object devices = new object();
422 | private static volatile USBAudioDeviceItems instane = null;
423 | public static USBAudioDeviceItems USBDevices
424 | {
425 | get
426 | {
427 | System.Threading.Mutex mutex = new System.Threading.Mutex();
428 | mutex.WaitOne();
429 | if (instane == null) //双检查
430 | {
431 | lock (devices)
432 | {
433 | if (instane == null)
434 | {
435 | instane = new USBAudioDeviceItems();
436 | ManagementObjectSearcher mo_search1 = new ManagementObjectSearcher("Select * From Win32_SoundDevice");
437 | ManagementObjectSearcher mo_search2 = new ManagementObjectSearcher("Select * From CIM_USBDevice");
438 | foreach (ManagementObject sound_info in mo_search1.Get())
439 | {
440 | if (sound_info["Name"] == null) continue;
441 | if (sound_info["DeviceID"] == null) continue;
442 | string sound_device_name = sound_info["Name"].ToString();
443 | string sound_device_id = sound_info["DeviceID"].ToString();
444 | if (sound_device_id.Split('\\').Length != 3) continue;
445 | if (sound_device_id.Split('\\')[1].Split('&').Length != 3) continue;
446 |
447 | foreach (ManagementObject usb_info in mo_search2.Get())
448 | {
449 | if (usb_info["Name"] == null) continue;
450 | if (usb_info["DeviceID"] == null) continue;
451 | string usb_device_name = usb_info["Name"].ToString();
452 | if (!usb_device_name.ToLower().Contains("usb composite device")) continue;
453 | string usb_device_id = usb_info["DeviceID"].ToString();
454 | if (usb_device_id.Split('\\').Length != 3) continue;
455 | if (usb_device_id.Split('\\')[1].Split('&').Length != 2) continue;
456 |
457 | if (sound_device_id.Split('\\')[1].Split('&')[0] == usb_device_id.Split('\\')[1].Split('&')[0]
458 | && sound_device_id.Split('\\')[1].Split('&')[1] == usb_device_id.Split('\\')[1].Split('&')[1])
459 | {
460 | string vid = sound_device_id.Split('\\')[1].Split('&')[0];
461 | string pid = sound_device_id.Split('\\')[1].Split('&')[1];
462 | //MessageBox.Show("", sound_device_name + "|" + usb_device_name);
463 | instane.Add(sound_device_name, sound_device_id);
464 | }
465 |
466 | }
467 | }
468 | }
469 | }
470 | }
471 | mutex.Close();
472 | return instane;
473 |
474 | }
475 | }
476 | }
477 |
478 | }
--------------------------------------------------------------------------------
/AccTimeBenchmark/Forms/Form1.cs:
--------------------------------------------------------------------------------
1 | using iTuner;
2 | using Microsoft.Win32.SafeHandles;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Diagnostics;
6 | using System.Drawing;
7 | using System.IO;
8 | using System.IO.MemoryMappedFiles;
9 | using System.Linq;
10 | using System.Reflection;
11 | using System.Runtime.InteropServices;
12 | using System.Text;
13 | using System.Threading;
14 | using System.Threading.Tasks;
15 | using System.Windows.Forms;
16 |
17 |
18 |
19 | namespace AccTimeBenchmark
20 | {
21 | public partial class Form1 : Form
22 | {
23 | private static UsbDisk UdObj;
24 | private static string diskRootPath;
25 | //private long dataLength = 1073737728L;
26 | private long dataLength = 536866816L;
27 | private int LoopTime4k = 30;
28 | //private long test4kCount = 8192 * 8192;
29 | private static uint FILE_FLAG_NO_BUFFERING = 536870912u;
30 | private static uint FILE_FLAG_WRITE_THROUGH = 2147483648u;
31 | private static uint file_flags = FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
32 | [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
33 | private static extern SafeFileHandle CreateFile(string lpFileName, FileAccess dwDesiredAccess, FileShare dwShareMode, IntPtr lpSecurityAttributes, FileMode dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
34 |
35 | private DateTime start4kTime;
36 |
37 | private static CancellationTokenSource cts = new CancellationTokenSource();
38 |
39 | private void GenerateRandomArray(byte[] rnd_array)
40 | {
41 | Random random = new Random();
42 | for (int i = 0; i < rnd_array.Length; i++)
43 | {
44 | rnd_array[i] = (byte)random.Next(255);
45 | }
46 | }
47 | Thread tBench;
48 | public Form1()
49 | {
50 | AutoScaleBaseSize = new Size(3, 10);
51 | InitializeComponent();
52 |
53 |
54 | }
55 |
56 | private void Form1_Load(object sender, EventArgs e)
57 | {
58 |
59 | SWOnline swo = new SWOnline("https://bbs.luobotou.org/app/wtgbench.txt"); //
60 | Thread threadUpdate = new Thread(swo.Update);
61 | threadUpdate.Start();
62 | GetUdiskList.LoadUDList(comboBoxDisk);
63 |
64 | Text += Application.ProductVersion;
65 | //Graphics graphics = CreateGraphics();
66 | //float dpiX = graphics.DpiX;
67 | //Width = (int)(900 * (dpiX / 96.0));
68 | //Height = (int)(650 * (dpiX / 96.0));
69 |
70 | labelSysversion.Text = SysInfo.GetSysVersion(); ;
71 | labelcpu.Text = SysInfo.GetCPUModel();
72 |
73 | }
74 | private double WriteSeq(string path, object ctobj)
75 | {
76 |
77 | CancellationToken token = (CancellationToken)ctobj;
78 |
79 | FileInfo fileInfo = new FileInfo(path);
80 | fileInfo.Delete();
81 | SafeFileHandle safeFileHandle = CreateFile(path, FileAccess.ReadWrite, FileShare.None, IntPtr.Zero, FileMode.OpenOrCreate, file_flags, IntPtr.Zero);
82 |
83 | FileStream fileStream = new FileStream(safeFileHandle, FileAccess.ReadWrite, 4096, false);
84 | Stopwatch sw = new Stopwatch();
85 | sw.Start();
86 | int seqSize = 67108864;
87 | byte[] seqBuffer = new byte[seqSize];
88 | GenerateRandomArray(seqBuffer);
89 | List seqPoints = new List();
90 | long testDuration = 10 * 1000;
91 | long maximumDataLength = 10737418240L;
92 | for (dataLength = 0L; ; dataLength += seqSize)
93 | {
94 | if (token.IsCancellationRequested)
95 | {
96 | break;
97 | }
98 | fileStream.Position = dataLength % maximumDataLength;
99 |
100 | long preTime = sw.ElapsedMilliseconds;
101 | fileStream.Write(seqBuffer, 0, seqSize);
102 | fileStream.Flush();
103 | long curTime = sw.ElapsedMilliseconds;
104 | seqPoints.Add((seqSize / (1024.0 * 1024)) / ((curTime - preTime) / 1000.0));
105 | progressBar1.Invoke(new Action(() =>
106 | {
107 | int val = (int)((sw.ElapsedMilliseconds / (double)testDuration) * 100);
108 | progressBar1.Value = val <= 100 ? val : 100;
109 | }));
110 | if (sw.ElapsedMilliseconds > testDuration)
111 | break;
112 | }
113 | sw.Stop();
114 | fileStream.Close();
115 | return seqPoints.Average();
116 | }
117 | private long ReadWrite(FileStream fileStream, long dataLength, byte[] buffer, int[] ioSizes, long runTime, float seqness, float writep, object ctobj)
118 | {
119 | CancellationToken token = (CancellationToken)ctobj;
120 | Random random = new Random();
121 |
122 | Stopwatch sw = new Stopwatch();
123 | sw.Start();
124 | long num = 0L;
125 | long previousPosition = 0L;
126 | for (; sw.ElapsedMilliseconds <= runTime; num += 1L)
127 | {
128 | int length = ioSizes[random.Next(10)];
129 | if (token.IsCancellationRequested)
130 | {
131 | break;
132 | }
133 | if (length == 0)
134 | continue;
135 | long num2 = random.Next((int)(dataLength / length + 1));
136 |
137 | if (random.NextDouble() < seqness)
138 | {
139 | fileStream.Position = previousPosition;
140 | }
141 | else
142 | {
143 | fileStream.Position = num2 * length;
144 | }
145 | if (random.NextDouble() < writep)
146 | {
147 | fileStream.Write(buffer, 0, length);
148 | }
149 | else
150 | {
151 | fileStream.Read(buffer, 0, length);
152 | }
153 | previousPosition = num2 * length + length;
154 |
155 | fileStream.Flush();
156 | }
157 |
158 |
159 | return num;
160 | }
161 | private long RandomReadWrite(FileStream fileStream, byte[] buffer, int length, long runTime, bool write, object ctobj)
162 | {
163 | CancellationToken token = (CancellationToken)ctobj;
164 | Random random = new Random();
165 | GenerateRandomArray(buffer);
166 | while (DateTime.Now < start4kTime)
167 | {
168 | Thread.Sleep(10);
169 | }
170 | Stopwatch sw = new Stopwatch();
171 | sw.Start();
172 | long num = 0L;
173 | for (; sw.ElapsedMilliseconds <= runTime; num += 1L)
174 | {
175 | if (token.IsCancellationRequested)
176 | {
177 | Console.WriteLine("Cancel Req");
178 | break;
179 | }
180 | long num2 = random.Next((int)(dataLength / length + 1));
181 |
182 | fileStream.Position = num2 * length;
183 | if (write)
184 | fileStream.Write(buffer, 0, length);
185 | else
186 | fileStream.Read(buffer, 0, length);
187 | fileStream.Flush();
188 | }
189 |
190 |
191 | return num;
192 | }
193 |
194 | private double Write4K_MultiThread(string path, int threadCount, List fsList, object ctobj)
195 | {
196 | long runTime = 30000;
197 | int length = 4096;
198 | byte[] buffer = new byte[length];
199 | GenerateRandomArray(buffer);
200 |
201 | //Thread.Sleep((int)runTime);
202 | start4kTime = DateTime.Now.AddSeconds(30);
203 | Task[] taskArray = new Task[threadCount];
204 | for (int i = 0; i < taskArray.Length; i++)
205 | {
206 | int index = i;
207 | taskArray[index] = Task.Factory.StartNew(() =>
208 | {
209 | Console.WriteLine(index);
210 | return RandomReadWrite(fsList[index], buffer, length, runTime, true, ctobj);
211 | }, (CancellationToken)ctobj);
212 |
213 | }
214 | Task.WaitAll(taskArray);
215 | long total_IO = 0;
216 | for (int i = 0; i < taskArray.Length; i++)
217 | {
218 | Console.WriteLine(taskArray[i].Result);
219 | total_IO += taskArray[i].Result;
220 |
221 | }
222 | Console.WriteLine("Finish");
223 |
224 | return total_IO / 30.0 * 4096.0 / 1024 / 1024;
225 | }
226 |
227 | private double Write4k(string path, ref double adjustResult, object ctsobj)
228 | {
229 | CancellationToken token = (CancellationToken)ctsobj;
230 |
231 | progressBar1.Invoke(new Action(() =>
232 | {
233 | progressBar1.Style = ProgressBarStyle.Marquee;
234 | }));
235 |
236 | Random random = new Random();
237 | byte[] buffer = new byte[4096];
238 | GenerateRandomArray(buffer);
239 |
240 | SafeFileHandle safeFileHandle = CreateFile(path, FileAccess.ReadWrite, FileShare.None, IntPtr.Zero, FileMode.OpenOrCreate, file_flags, IntPtr.Zero);
241 |
242 | FileStream fileStream = new FileStream(safeFileHandle, FileAccess.ReadWrite, 4096, false);
243 | fileStream.Position = dataLength;
244 | fileStream.Write(buffer, 0, 4096);
245 | Thread.Sleep(500);
246 | progressBar1.Invoke(new Action(() =>
247 | {
248 | progressBar1.Style = ProgressBarStyle.Blocks;
249 | }));
250 | List testPoints = new List();
251 | Stopwatch temp_timer = new Stopwatch();
252 | temp_timer.Start();
253 | long previousTime = 0L;
254 | long prenum = 0L;
255 | // int loopTimes = 30;
256 | for (long num = 0L; testPoints.Count < LoopTime4k; num += 1L)
257 | {
258 | if (token.IsCancellationRequested)
259 | {
260 | break;
261 | }
262 | long num2 = random.Next((int)(dataLength / 4096 + 1));
263 |
264 | long curTime = temp_timer.ElapsedMilliseconds;
265 | if (curTime - previousTime > 500)
266 | {
267 | double curSpeed = ((num - prenum) * 4096.0 / 1024 / 1024) / ((curTime - previousTime) / 1000.0);
268 | testPoints.Add(curSpeed);
269 | prenum = num;
270 | progressBar1.Invoke(new Action(() =>
271 | {
272 | progressBar1.Value = (int)(testPoints.Count / (double)LoopTime4k * 100.0);
273 | }));
274 | previousTime = temp_timer.ElapsedMilliseconds;
275 | }
276 | fileStream.Position = num2 * 4096;
277 | fileStream.Write(buffer, 0, 4096);
278 | fileStream.Flush();
279 | }
280 |
281 | fileStream.Close();
282 | temp_timer.Stop();
283 | if (token.IsCancellationRequested)
284 | {
285 | return 0.0;
286 | }
287 | progressBar1.Invoke(new Action(() => { progressBar1.Value = 100; }));
288 |
289 | double avg = testPoints.Average();
290 |
291 | chart1.Invoke(new Action(() =>
292 | {
293 |
294 | for (int i = 0; i < testPoints.Count(); i++)
295 | {
296 |
297 | chart1.Series[0].Points.AddXY(i / 2.0, testPoints[i]);
298 |
299 | }
300 |
301 | }));
302 |
303 | testPoints.AddRange(testPoints.GetRange(LoopTime4k / 2, LoopTime4k / 2));
304 |
305 | int cnt = testPoints.Count;
306 |
307 |
308 |
309 | for (int i = 0; i < cnt; i++)
310 | {
311 | if (testPoints[i] < avg * 0.5)
312 | {
313 | testPoints.Add(testPoints[i]);
314 | }
315 | }
316 | adjustResult = testPoints.Average();
317 |
318 | return avg;
319 | }
320 |
321 |
322 |
323 |
324 | private void SetTxt(TextBox tb, string text)
325 | {
326 | tb.Invoke(new Action(() => { tb.Text = text; }));
327 | }
328 | private void button1_Click(object sender, EventArgs e)
329 | {
330 |
331 | if (UdObj == null)
332 | {
333 | MessageBox.Show("请选择移动磁盘");
334 | return;
335 | }
336 | diskRootPath = UdObj.Volume.Substring(0, 1) + ":\\";
337 | if (checkBoxScenario.Checked)
338 | {
339 | //Write4K_MultiThread(txtUDisk.Text + "test.bin", 16);
340 | //return;
341 | }
342 |
343 | if (btnStart.Text == "开始")
344 | {
345 | cts.Dispose();
346 | cts = new CancellationTokenSource();
347 | tBench = new Thread(() =>
348 | {
349 | try
350 | {
351 |
352 | if (checkBoxFast.Checked)
353 | FastBenchmark(cts.Token);
354 | if (checkBoxThread.Checked)
355 | {
356 | if (DiskOperation.GetHardDiskFreeSpace(diskRootPath) < 20 * 1024 * 1024)
357 | {
358 | MessageBox.Show("至少需要20GB可用空间进行测试!");
359 | return;
360 | }
361 | if (checkBoxFast.Checked)
362 | Thread.Sleep(10000);
363 | MultiThreadBenchmark(cts.Token);
364 |
365 | }
366 | if (checkBoxFullSeq.Checked)
367 | {
368 | FullSeqBenchmark(cts.Token);
369 | Thread.Sleep(10000);
370 | }
371 | if (checkBoxScenario.Checked)
372 | {
373 | if (DiskOperation.GetHardDiskFreeSpace(diskRootPath) < 20 * 1024 * 1024)
374 | {
375 | MessageBox.Show("至少需要20GB可用空间进行测试!");
376 | return;
377 | }
378 | progressBar1.Invoke(new Action(() =>
379 | {
380 | progressBar1.Style = ProgressBarStyle.Marquee;
381 | }));
382 | List scenarios = new List();
383 | scenarios.Add(CSVReader.Read(@".\Scenarios\normal_web.csv"));
384 |
385 | long total_IO = ScenarioBenchmark(scenarios, cts.Token);
386 | labelSceRes.Invoke(new Action(() => { labelSceRes.Text = (total_IO / 1000).ToString(); }));
387 | progressBar1.Invoke(new Action(() =>
388 | {
389 | progressBar1.Style = ProgressBarStyle.Blocks;
390 | }));
391 | }
392 | }
393 | catch (Exception ex)
394 | {
395 | MessageBox.Show(ex.ToString());
396 | }
397 | btnStart.Invoke(new Action(() => { btnStart.Text = "开始"; }));
398 | });
399 | tBench.Start();
400 | btnStart.Text = "停止";
401 | }
402 | else
403 | {
404 | if (tBench != null)
405 | {
406 | cts.Cancel();
407 |
408 | }
409 | btnStart.Text = "开始";
410 | }
411 |
412 |
413 | }
414 | private long ScenarioBenchmark(List scenarios, object ctobj)
415 | {
416 | string path = diskRootPath + "test.bin";
417 | int length = 4096;
418 | int runTime = 5000;
419 | List fsList = new List();
420 | byte[] buffer = new byte[length];
421 | GenerateRandomArray(buffer);
422 | dataLength = 536866816L;
423 | for (int i = 0; i < 32; i++)
424 | {
425 | File.Delete(path + i.ToString());
426 | SafeFileHandle safeFileHandle = CreateFile(path + i.ToString(), FileAccess.ReadWrite, FileShare.None, IntPtr.Zero, FileMode.OpenOrCreate, file_flags, IntPtr.Zero);
427 |
428 | FileStream fileStream = new FileStream(safeFileHandle, FileAccess.ReadWrite, length, false);
429 | fileStream.Position = dataLength;
430 | fileStream.Write(buffer, 0, length);
431 |
432 | fsList.Add(fileStream);
433 | }
434 | buffer = new byte[16777216];
435 | GenerateRandomArray(buffer);
436 | Thread.Sleep(10000);
437 | long total_IO = 0;
438 | foreach (var sce in scenarios)
439 | {
440 | foreach (var testLine in sce.TestLines)
441 | {
442 | Task[] taskArray = new Task[testLine.Threads];
443 | for (int i = 0; i < taskArray.Length; i++)
444 | {
445 | int index = i;
446 | taskArray[index] = Task.Factory.StartNew(() =>
447 | {
448 | return ReadWrite(fsList[index], dataLength, buffer, testLine.IOSizes, runTime, testLine.SeqNess, testLine.WriteProportion, ctobj);
449 | }, (CancellationToken)ctobj);
450 |
451 | }
452 | Task.WaitAll(taskArray);
453 | for (int i = 0; i < taskArray.Length; i++)
454 | {
455 | total_IO += taskArray[i].Result;
456 | }
457 | }
458 | Thread.Sleep(10000);
459 | }
460 | for (int i = 0; i < 32; i++)
461 | {
462 | fsList[i].Close();
463 | File.Delete(path + i.ToString());
464 | }
465 | return total_IO;
466 |
467 |
468 | }
469 | private void MultiThreadBenchmark(object ctobj)
470 | {
471 | chartThreads.Invoke(new Action(() =>
472 | {
473 | chartThreads.ChartAreas[0].AxisX.IsLogarithmic = false;
474 | chartThreads.Series[0].Points.Clear();
475 |
476 | }));
477 | progressBar1.Invoke(new Action(() =>
478 | {
479 | progressBar1.Style = ProgressBarStyle.Marquee;
480 | }));
481 | string path = diskRootPath + "test.bin";
482 | int length = 4096;
483 | List fsList = new List();
484 | byte[] buffer = new byte[length];
485 | GenerateRandomArray(buffer);
486 | dataLength = 536866816L;
487 | for (int i = 0; i < 32; i++)
488 | {
489 | File.Delete(path + i.ToString());
490 | SafeFileHandle safeFileHandle = CreateFile(path + i.ToString(), FileAccess.ReadWrite, FileShare.None, IntPtr.Zero, FileMode.OpenOrCreate, file_flags, IntPtr.Zero);
491 |
492 | FileStream fileStream = new FileStream(safeFileHandle, FileAccess.ReadWrite, length, false);
493 | fileStream.Position = dataLength;
494 | fileStream.Write(buffer, 0, length);
495 |
496 | fsList.Add(fileStream);
497 | }
498 | StringBuilder csvBuilder = new StringBuilder();
499 |
500 |
501 | for (int i = 0; i <= 5; i++)
502 | {
503 |
504 | double result = Write4K_MultiThread(diskRootPath + "test.bin", 1 << i, fsList, ctobj);
505 | chartThreads.Invoke(new Action(() =>
506 | {
507 | chartThreads.Series[0].Points.AddXY(1 << i, result);
508 | chartThreads.ChartAreas[0].AxisX.IsLogarithmic = true;
509 | }));
510 | csvBuilder.Append(1 << i);
511 | csvBuilder.Append(",");
512 | csvBuilder.Append(result);
513 | csvBuilder.AppendLine(",");
514 |
515 | if (i < 5)
516 | Thread.Sleep(20000);
517 | }
518 | for (int i = 0; i < 32; i++)
519 | {
520 | fsList[i].Close();
521 | File.Delete(path + i.ToString());
522 | }
523 | progressBar1.Invoke(new Action(() =>
524 | {
525 | progressBar1.Style = ProgressBarStyle.Continuous;
526 | progressBar1.Value = 100;
527 | }));
528 | File.WriteAllText("Multi4k_" + DateTime.Now.ToString("yyyy-MM-ddTHH-mm-ss") + ".csv", csvBuilder.ToString());
529 |
530 | }
531 |
532 | private void FullSeqBenchmark(object ctobj)
533 | {
534 | chartFullSeq.Invoke(new Action(() =>
535 | {
536 | //chartFullSeq.Series[0].Points.Clear();
537 | }));
538 | CancellationToken token = (CancellationToken)ctobj;
539 |
540 | progressBar1.Invoke(new Action(() =>
541 | {
542 | progressBar1.Style = ProgressBarStyle.Marquee;
543 | }));
544 | float ioLengthMB = 64;
545 | int steplengthMB = 1024;
546 |
547 | Random random = new Random();
548 | byte[] buffer = new byte[(int)(1024 * 1024 * ioLengthMB)];
549 | GenerateRandomArray(buffer);
550 | string path = diskRootPath + "test.bin";
551 | if (File.Exists(path))
552 | File.Delete(path);
553 | long freeSpace = DiskOperation.GetHardDiskFreeSpace(diskRootPath);
554 | //CreateDummyFile(path, freeSpace - 100 * 1024 * 1024);
555 |
556 | SafeFileHandle safeFileHandle = CreateFile(path, FileAccess.ReadWrite, FileShare.None, IntPtr.Zero, FileMode.OpenOrCreate, file_flags, IntPtr.Zero);
557 |
558 | using FileStream fileStream = new FileStream(safeFileHandle, FileAccess.ReadWrite, 0, false);
559 |
560 | List testPoints = new List();
561 | Stopwatch speedTimer = new Stopwatch();
562 | speedTimer.Start();
563 | Thread.Sleep(3000);
564 | long previousPos = 0L;
565 | StringBuilder csvBuilder = new StringBuilder();
566 |
567 | for (int num = 0; num < freeSpace / (steplengthMB * 1024 * 1024); num++)
568 | {
569 | if (token.IsCancellationRequested)
570 | {
571 | break;
572 | }
573 |
574 | //Write steplengthMB
575 | double previousTime = speedTimer.Elapsed.TotalMilliseconds;
576 | for (int p = 0; p < steplengthMB / ioLengthMB; p++)
577 | {
578 | fileStream.Position = previousPos + (int)(1024 * 1024 * p * ioLengthMB);
579 | fileStream.Write(buffer, 0, (int)(1024 * 1024 * ioLengthMB));
580 | //fileStream.Flush();
581 | }
582 | double curTime = speedTimer.Elapsed.TotalMilliseconds;
583 |
584 | double curSpeed = (float)steplengthMB / ((curTime - previousTime) / 1000.0);
585 | Debug.WriteLine(curSpeed);
586 |
587 | previousPos = previousPos + steplengthMB * 1024 * 1024;
588 |
589 | if (num == 0)
590 | continue;
591 | _ = UpdateChart(csvBuilder, num, curSpeed, steplengthMB);
592 |
593 | }
594 |
595 | fileStream.Close();
596 | File.Delete(path);
597 | speedTimer.Stop();
598 | File.WriteAllText("FullSeq_" + DateTime.Now.ToString("yyyy-MM-ddTHH-mm-ss") + ".csv", csvBuilder.ToString());
599 | progressBar1.Invoke(new Action(() =>
600 | {
601 | progressBar1.Style = ProgressBarStyle.Continuous;
602 | progressBar1.Value = 100;
603 | }));
604 |
605 | }
606 | private async Task UpdateChart(StringBuilder csvBuilder, int num, double curSpeed, int steplengthMB)
607 | {
608 | await Task.Run(() =>
609 | {
610 | chartFullSeq.Invoke(new Action(() =>
611 | {
612 | chartFullSeq.Series[0].Points.AddXY((num - 1) / (1024.0 / steplengthMB), curSpeed);
613 |
614 | }));
615 |
616 | csvBuilder.Append(((num - 1) / 4.0).ToString());
617 | csvBuilder.Append(",");
618 | csvBuilder.Append(curSpeed);
619 | csvBuilder.AppendLine(",");
620 | });
621 | }
622 |
623 | private void FastBenchmark(object ctobj)
624 | {
625 | chart1.Invoke(new Action(() =>
626 | {
627 | chart1.Series[0].Points.Clear();
628 | }));
629 | double adj4k = 0;
630 | double timeseq = WriteSeq(diskRootPath + "test.bin", ctobj);
631 |
632 | SetTxt(txtSeqResult, timeseq.ToString("f4") + " MB/s");
633 | double time4k = Write4k(diskRootPath + "test.bin", ref adj4k, ctobj);
634 | txt4kResult.Invoke(new Action(() => { txt4kResult.Text = time4k.ToString("f4") + " MB/s"; }));
635 | txtA4kResult.Invoke(new Action(() => { txtA4kResult.Text = adj4k.ToString("f4") + " MB/s"; }));
636 | File.Delete(diskRootPath + "test.bin");
637 |
638 | double score = adj4k + Math.Log(1 + (timeseq / 1000));
639 | int lv = 0;
640 | if (score > 30)
641 | {
642 | lv = 5;
643 | }
644 | else if (score > 10)
645 | {
646 | lv = 4;
647 | }
648 | else if (score > 0.8)
649 | {
650 | lv = 3;
651 | }
652 | else if (score > 0.3)
653 | {
654 | lv = 2;
655 | }
656 | else
657 | {
658 | lv = 1;
659 | }
660 |
661 | string ln = "Error";
662 | Color lc = Color.Yellow;
663 | Image L1 = Properties.Resources.grey;
664 | Image L2 = Properties.Resources.grey;
665 | Image L3 = Properties.Resources.grey;
666 | Image L4 = Properties.Resources.grey;
667 | if (lv == 1)
668 | {
669 | ln = "Steel";
670 | lc = Color.SteelBlue;
671 |
672 | }
673 | else if (lv == 2)
674 | {
675 | ln = "Bronze";
676 | lc = Color.Crimson;
677 | L1 = Properties.Resources.orange;
678 | }
679 | else if (lv == 3)
680 | {
681 | ln = "Silver";
682 | lc = Color.Silver;
683 | L1 = Properties.Resources.orange;
684 | L2 = Properties.Resources.orange;
685 | }
686 | else if (lv == 4)
687 | {
688 | ln = "Gold";
689 | lc = Color.Gold;
690 | L1 = Properties.Resources.orange;
691 | L2 = Properties.Resources.orange;
692 | L3 = Properties.Resources.orange;
693 | }
694 | else if (lv == 5)
695 | {
696 | ln = "Platinum";
697 | lc = Color.White;
698 | L1 = Properties.Resources.orange;
699 | L2 = Properties.Resources.orange;
700 | L3 = Properties.Resources.orange;
701 | L4 = Properties.Resources.orange;
702 | }
703 | labelLevel.Invoke(new Action(() =>
704 | {
705 | labelLevel.Text = ln;
706 | labelLevel.ForeColor = lc;
707 | labelLevel.Visible = true;
708 | }));
709 |
710 | pictureBoxL1.Invoke(new Action(() =>
711 | {
712 | pictureBoxL1.Image = L1;
713 | pictureBoxL1.Visible = true;
714 | }));
715 | pictureBoxL2.Invoke(new Action(() =>
716 | {
717 | pictureBoxL2.Image = L2;
718 | pictureBoxL2.Visible = true;
719 | }));
720 | pictureBoxL3.Invoke(new Action(() =>
721 | {
722 | pictureBoxL3.Image = L3;
723 | pictureBoxL3.Visible = true;
724 | }));
725 | pictureBoxL4.Invoke(new Action(() =>
726 | {
727 | pictureBoxL4.Image = L4;
728 | pictureBoxL4.Visible = true;
729 | }));
730 |
731 | }
732 |
733 | private void Form1_FormClosing(object sender, FormClosingEventArgs e)
734 | {
735 | Environment.Exit(0);
736 | }
737 |
738 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
739 | {
740 | Process.Start("https://bbs.luobotou.org/forum-88-1.html");
741 | }
742 |
743 | private void labelLevel_Click(object sender, EventArgs e)
744 | {
745 | MessageBox.Show("由高到低有Platinum、Gold、Silver、Bronze、Steel共5个等级。\nSilver及以上可用于制作Windows To Go,等级越高使用体验越好。");
746 | }
747 |
748 | private void pictureBox1_Click(object sender, EventArgs e)
749 | {
750 | Process.Start("https://bbs.luobotou.org/forum-88-1.html");
751 | }
752 |
753 | private void pictureBox2_Click(object sender, EventArgs e)
754 | {
755 | Process.Start("https://bbs.luobotou.org/forum-88-1.html");
756 | }
757 |
758 | private void chartFullSeq_Click(object sender, EventArgs e)
759 | {
760 |
761 | }
762 |
763 | private void comboBoxDisk_SelectedIndexChanged(object sender, EventArgs e)
764 | {
765 | UdObj = (UsbDisk)comboBoxDisk.SelectedItem;
766 | }
767 |
768 | private void comboBoxDisk_MouseHover(object sender, EventArgs e)
769 | {
770 | try
771 | {
772 | toolTip1.SetToolTip(this.comboBoxDisk, comboBoxDisk.SelectedItem.ToString()); ;
773 | }
774 | catch (Exception ex)
775 | {
776 | Debug.WriteLine(ex);
777 | }
778 | }
779 |
780 | }
781 | }
782 |
--------------------------------------------------------------------------------
/AccTimeBenchmark/Forms/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace AccTimeBenchmark
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows 窗体设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.components = new System.ComponentModel.Container();
32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
33 | System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
34 | System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
35 | System.Windows.Forms.DataVisualization.Charting.Title title1 = new System.Windows.Forms.DataVisualization.Charting.Title();
36 | System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
37 | System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
38 | System.Windows.Forms.DataVisualization.Charting.DataPoint dataPoint1 = new System.Windows.Forms.DataVisualization.Charting.DataPoint(1D, 0D);
39 | System.Windows.Forms.DataVisualization.Charting.Title title2 = new System.Windows.Forms.DataVisualization.Charting.Title();
40 | System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea3 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
41 | System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
42 | System.Windows.Forms.DataVisualization.Charting.Title title3 = new System.Windows.Forms.DataVisualization.Charting.Title();
43 | this.comboBoxDisk = new System.Windows.Forms.ComboBox();
44 | this.groupBox2 = new System.Windows.Forms.GroupBox();
45 | this.checkBoxFast = new System.Windows.Forms.CheckBox();
46 | this.checkBoxFullSeq = new System.Windows.Forms.CheckBox();
47 | this.checkBoxThread = new System.Windows.Forms.CheckBox();
48 | this.progressBar1 = new System.Windows.Forms.ProgressBar();
49 | this.groupBox3 = new System.Windows.Forms.GroupBox();
50 | this.pictureBoxL1 = new System.Windows.Forms.PictureBox();
51 | this.pictureBoxL2 = new System.Windows.Forms.PictureBox();
52 | this.pictureBoxL3 = new System.Windows.Forms.PictureBox();
53 | this.pictureBoxL4 = new System.Windows.Forms.PictureBox();
54 | this.label1 = new System.Windows.Forms.Label();
55 | this.labelSceRes = new System.Windows.Forms.Label();
56 | this.labelLevel = new System.Windows.Forms.Label();
57 | this.label7 = new System.Windows.Forms.Label();
58 | this.txtSeqResult = new System.Windows.Forms.TextBox();
59 | this.label6 = new System.Windows.Forms.Label();
60 | this.txtA4kResult = new System.Windows.Forms.TextBox();
61 | this.label5 = new System.Windows.Forms.Label();
62 | this.checkBoxScenario = new System.Windows.Forms.CheckBox();
63 | this.btnStart = new System.Windows.Forms.Button();
64 | this.txt4kResult = new System.Windows.Forms.TextBox();
65 | this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
66 | this.chartThreads = new System.Windows.Forms.DataVisualization.Charting.Chart();
67 | this.pictureBox1 = new System.Windows.Forms.PictureBox();
68 | this.pictureBox2 = new System.Windows.Forms.PictureBox();
69 | this.chartFullSeq = new System.Windows.Forms.DataVisualization.Charting.Chart();
70 | this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
71 | this.linkLabel1 = new System.Windows.Forms.LinkLabel();
72 | this.labelSysversion = new System.Windows.Forms.Label();
73 | this.labelcpu = new System.Windows.Forms.Label();
74 | this.groupBox2.SuspendLayout();
75 | this.groupBox3.SuspendLayout();
76 | ((System.ComponentModel.ISupportInitialize)(this.pictureBoxL1)).BeginInit();
77 | ((System.ComponentModel.ISupportInitialize)(this.pictureBoxL2)).BeginInit();
78 | ((System.ComponentModel.ISupportInitialize)(this.pictureBoxL3)).BeginInit();
79 | ((System.ComponentModel.ISupportInitialize)(this.pictureBoxL4)).BeginInit();
80 | ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
81 | ((System.ComponentModel.ISupportInitialize)(this.chartThreads)).BeginInit();
82 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
83 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
84 | ((System.ComponentModel.ISupportInitialize)(this.chartFullSeq)).BeginInit();
85 | this.SuspendLayout();
86 | //
87 | // comboBoxDisk
88 | //
89 | this.comboBoxDisk.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
90 | this.comboBoxDisk.FormattingEnabled = true;
91 | this.comboBoxDisk.Location = new System.Drawing.Point(55, 93);
92 | this.comboBoxDisk.Name = "comboBoxDisk";
93 | this.comboBoxDisk.Size = new System.Drawing.Size(376, 25);
94 | this.comboBoxDisk.TabIndex = 54;
95 | this.comboBoxDisk.SelectedIndexChanged += new System.EventHandler(this.comboBoxDisk_SelectedIndexChanged);
96 | this.comboBoxDisk.MouseHover += new System.EventHandler(this.comboBoxDisk_MouseHover);
97 | //
98 | // groupBox2
99 | //
100 | this.groupBox2.Controls.Add(this.checkBoxFast);
101 | this.groupBox2.Controls.Add(this.checkBoxFullSeq);
102 | this.groupBox2.Controls.Add(this.checkBoxThread);
103 | this.groupBox2.Controls.Add(this.progressBar1);
104 | this.groupBox2.Controls.Add(this.groupBox3);
105 | this.groupBox2.Controls.Add(this.checkBoxScenario);
106 | this.groupBox2.Controls.Add(this.btnStart);
107 | this.groupBox2.Location = new System.Drawing.Point(28, 135);
108 | this.groupBox2.Margin = new System.Windows.Forms.Padding(4);
109 | this.groupBox2.Name = "groupBox2";
110 | this.groupBox2.Padding = new System.Windows.Forms.Padding(4);
111 | this.groupBox2.Size = new System.Drawing.Size(431, 338);
112 | this.groupBox2.TabIndex = 9;
113 | this.groupBox2.TabStop = false;
114 | this.groupBox2.Text = "性能测试";
115 | //
116 | // checkBoxFast
117 | //
118 | this.checkBoxFast.AutoSize = true;
119 | this.checkBoxFast.Checked = true;
120 | this.checkBoxFast.CheckState = System.Windows.Forms.CheckState.Checked;
121 | this.checkBoxFast.Location = new System.Drawing.Point(28, 27);
122 | this.checkBoxFast.Margin = new System.Windows.Forms.Padding(5);
123 | this.checkBoxFast.Name = "checkBoxFast";
124 | this.checkBoxFast.Size = new System.Drawing.Size(89, 23);
125 | this.checkBoxFast.TabIndex = 5;
126 | this.checkBoxFast.Text = "快速测试";
127 | this.checkBoxFast.UseVisualStyleBackColor = true;
128 | //
129 | // checkBoxFullSeq
130 | //
131 | this.checkBoxFullSeq.AutoSize = true;
132 | this.checkBoxFullSeq.Checked = true;
133 | this.checkBoxFullSeq.CheckState = System.Windows.Forms.CheckState.Checked;
134 | this.checkBoxFullSeq.Location = new System.Drawing.Point(28, 56);
135 | this.checkBoxFullSeq.Margin = new System.Windows.Forms.Padding(5);
136 | this.checkBoxFullSeq.Name = "checkBoxFullSeq";
137 | this.checkBoxFullSeq.Size = new System.Drawing.Size(89, 23);
138 | this.checkBoxFullSeq.TabIndex = 6;
139 | this.checkBoxFullSeq.Text = "全盘写入";
140 | this.checkBoxFullSeq.UseVisualStyleBackColor = true;
141 | //
142 | // checkBoxThread
143 | //
144 | this.checkBoxThread.AutoSize = true;
145 | this.checkBoxThread.Checked = true;
146 | this.checkBoxThread.CheckState = System.Windows.Forms.CheckState.Checked;
147 | this.checkBoxThread.Location = new System.Drawing.Point(132, 27);
148 | this.checkBoxThread.Margin = new System.Windows.Forms.Padding(5);
149 | this.checkBoxThread.Name = "checkBoxThread";
150 | this.checkBoxThread.Size = new System.Drawing.Size(126, 23);
151 | this.checkBoxThread.TabIndex = 4;
152 | this.checkBoxThread.Text = "多线程(6mins)";
153 | this.checkBoxThread.UseVisualStyleBackColor = true;
154 | //
155 | // progressBar1
156 | //
157 | this.progressBar1.Location = new System.Drawing.Point(28, 96);
158 | this.progressBar1.Margin = new System.Windows.Forms.Padding(6);
159 | this.progressBar1.Name = "progressBar1";
160 | this.progressBar1.Size = new System.Drawing.Size(375, 17);
161 | this.progressBar1.TabIndex = 2;
162 | //
163 | // groupBox3
164 | //
165 | this.groupBox3.Controls.Add(this.pictureBoxL1);
166 | this.groupBox3.Controls.Add(this.pictureBoxL2);
167 | this.groupBox3.Controls.Add(this.pictureBoxL3);
168 | this.groupBox3.Controls.Add(this.pictureBoxL4);
169 | this.groupBox3.Controls.Add(this.label1);
170 | this.groupBox3.Controls.Add(this.labelSceRes);
171 | this.groupBox3.Controls.Add(this.labelLevel);
172 | this.groupBox3.Controls.Add(this.label7);
173 | this.groupBox3.Controls.Add(this.txtSeqResult);
174 | this.groupBox3.Controls.Add(this.label6);
175 | this.groupBox3.Controls.Add(this.txtA4kResult);
176 | this.groupBox3.Controls.Add(this.label5);
177 | this.groupBox3.Location = new System.Drawing.Point(0, 127);
178 | this.groupBox3.Margin = new System.Windows.Forms.Padding(6);
179 | this.groupBox3.Name = "groupBox3";
180 | this.groupBox3.Padding = new System.Windows.Forms.Padding(6);
181 | this.groupBox3.Size = new System.Drawing.Size(431, 199);
182 | this.groupBox3.TabIndex = 1;
183 | this.groupBox3.TabStop = false;
184 | this.groupBox3.Text = "测试结果";
185 | //
186 | // pictureBoxL1
187 | //
188 | this.pictureBoxL1.Image = global::AccTimeBenchmark.Properties.Resources.orange;
189 | this.pictureBoxL1.Location = new System.Drawing.Point(271, 111);
190 | this.pictureBoxL1.Name = "pictureBoxL1";
191 | this.pictureBoxL1.Size = new System.Drawing.Size(28, 33);
192 | this.pictureBoxL1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
193 | this.pictureBoxL1.TabIndex = 15;
194 | this.pictureBoxL1.TabStop = false;
195 | this.pictureBoxL1.Visible = false;
196 | //
197 | // pictureBoxL2
198 | //
199 | this.pictureBoxL2.Image = global::AccTimeBenchmark.Properties.Resources.grey;
200 | this.pictureBoxL2.Location = new System.Drawing.Point(303, 111);
201 | this.pictureBoxL2.Name = "pictureBoxL2";
202 | this.pictureBoxL2.Size = new System.Drawing.Size(28, 33);
203 | this.pictureBoxL2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
204 | this.pictureBoxL2.TabIndex = 14;
205 | this.pictureBoxL2.TabStop = false;
206 | this.pictureBoxL2.Visible = false;
207 | //
208 | // pictureBoxL3
209 | //
210 | this.pictureBoxL3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBoxL3.Image")));
211 | this.pictureBoxL3.Location = new System.Drawing.Point(335, 111);
212 | this.pictureBoxL3.Name = "pictureBoxL3";
213 | this.pictureBoxL3.Size = new System.Drawing.Size(28, 33);
214 | this.pictureBoxL3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
215 | this.pictureBoxL3.TabIndex = 13;
216 | this.pictureBoxL3.TabStop = false;
217 | this.pictureBoxL3.Visible = false;
218 | //
219 | // pictureBoxL4
220 | //
221 | this.pictureBoxL4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBoxL4.Image")));
222 | this.pictureBoxL4.Location = new System.Drawing.Point(367, 111);
223 | this.pictureBoxL4.Name = "pictureBoxL4";
224 | this.pictureBoxL4.Size = new System.Drawing.Size(28, 33);
225 | this.pictureBoxL4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
226 | this.pictureBoxL4.TabIndex = 12;
227 | this.pictureBoxL4.TabStop = false;
228 | this.pictureBoxL4.Visible = false;
229 | //
230 | // label1
231 | //
232 | this.label1.AutoSize = true;
233 | this.label1.Location = new System.Drawing.Point(23, 150);
234 | this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
235 | this.label1.Name = "label1";
236 | this.label1.Size = new System.Drawing.Size(105, 20);
237 | this.label1.TabIndex = 11;
238 | this.label1.Text = "场景测试(v1.0)";
239 | //
240 | // labelSceRes
241 | //
242 | this.labelSceRes.AutoSize = true;
243 | this.labelSceRes.Font = new System.Drawing.Font("Microsoft YaHei", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
244 | this.labelSceRes.Location = new System.Drawing.Point(136, 156);
245 | this.labelSceRes.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
246 | this.labelSceRes.Name = "labelSceRes";
247 | this.labelSceRes.Size = new System.Drawing.Size(16, 21);
248 | this.labelSceRes.TabIndex = 10;
249 | this.labelSceRes.Text = "-";
250 | //
251 | // labelLevel
252 | //
253 | this.labelLevel.AutoSize = true;
254 | this.labelLevel.BackColor = System.Drawing.Color.Black;
255 | this.labelLevel.Cursor = System.Windows.Forms.Cursors.Hand;
256 | this.labelLevel.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
257 | this.labelLevel.ForeColor = System.Drawing.SystemColors.ActiveBorder;
258 | this.labelLevel.Location = new System.Drawing.Point(135, 111);
259 | this.labelLevel.Name = "labelLevel";
260 | this.labelLevel.Size = new System.Drawing.Size(133, 34);
261 | this.labelLevel.TabIndex = 9;
262 | this.labelLevel.Text = "Platinum";
263 | this.labelLevel.Visible = false;
264 | this.labelLevel.Click += new System.EventHandler(this.labelLevel_Click);
265 | //
266 | // label7
267 | //
268 | this.label7.AutoSize = true;
269 | this.label7.Location = new System.Drawing.Point(23, 105);
270 | this.label7.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);/////////
271 | this.label7.Name = "label7";
272 | this.label7.Size = new System.Drawing.Size(38, 20);
273 | this.label7.TabIndex = 8;
274 | this.label7.Text = "等级";
275 | //
276 | // txtSeqResult
277 | //
278 | this.txtSeqResult.Location = new System.Drawing.Point(132, 32);
279 | this.txtSeqResult.Margin = new System.Windows.Forms.Padding(4);
280 | this.txtSeqResult.Name = "txtSeqResult";
281 | this.txtSeqResult.ReadOnly = true;
282 | this.txtSeqResult.Size = new System.Drawing.Size(263, 24);
283 | this.txtSeqResult.TabIndex = 7;
284 | //
285 | // label6
286 | //
287 | this.label6.AutoSize = true;
288 | this.label6.Location = new System.Drawing.Point(23, 35);
289 | this.label6.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
290 | this.label6.Name = "label6";
291 | this.label6.Size = new System.Drawing.Size(67, 20);
292 | this.label6.TabIndex = 6;
293 | this.label6.Text = "连续写入";
294 | //
295 | // txtA4kResult
296 | //
297 | this.txtA4kResult.Location = new System.Drawing.Point(132, 67);
298 | this.txtA4kResult.Margin = new System.Windows.Forms.Padding(6);
299 | this.txtA4kResult.Name = "txtA4kResult";
300 | this.txtA4kResult.ReadOnly = true;
301 | this.txtA4kResult.Size = new System.Drawing.Size(263, 24);
302 | this.txtA4kResult.TabIndex = 5;
303 | //
304 | // label5
305 | //
306 | this.label5.AutoSize = true;
307 | this.label5.Location = new System.Drawing.Point(23, 71);
308 | this.label5.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
309 | this.label5.Name = "label5";
310 | this.label5.Size = new System.Drawing.Size(85, 20);
311 | this.label5.TabIndex = 4;
312 | this.label5.Text = "4K随机写入";
313 | //
314 | // checkBoxScenario
315 | //
316 | this.checkBoxScenario.AutoSize = true;
317 | this.checkBoxScenario.Checked = true;
318 | this.checkBoxScenario.CheckState = System.Windows.Forms.CheckState.Checked;
319 | this.checkBoxScenario.Location = new System.Drawing.Point(132, 56);
320 | this.checkBoxScenario.Margin = new System.Windows.Forms.Padding(5);
321 | this.checkBoxScenario.Name = "checkBoxScenario";
322 | this.checkBoxScenario.Size = new System.Drawing.Size(149, 23);
323 | this.checkBoxScenario.TabIndex = 3;
324 | this.checkBoxScenario.Text = "场景测试(15mins)";
325 | this.checkBoxScenario.UseVisualStyleBackColor = true;
326 | //
327 | // btnStart
328 | //
329 | this.btnStart.Location = new System.Drawing.Point(328, 27);
330 | this.btnStart.Margin = new System.Windows.Forms.Padding(6);
331 | this.btnStart.Name = "btnStart";
332 | this.btnStart.Size = new System.Drawing.Size(75, 47);
333 | this.btnStart.TabIndex = 0;
334 | this.btnStart.Text = "开始";
335 | this.btnStart.UseVisualStyleBackColor = true;
336 | this.btnStart.Click += new System.EventHandler(this.button1_Click);
337 | //
338 | // txt4kResult
339 | //
340 | this.txt4kResult.Location = new System.Drawing.Point(75, 527);
341 | this.txt4kResult.Margin = new System.Windows.Forms.Padding(6);
342 | this.txt4kResult.Name = "txt4kResult";
343 | this.txt4kResult.ReadOnly = true;
344 | this.txt4kResult.Size = new System.Drawing.Size(255, 24);
345 | this.txt4kResult.TabIndex = 1;
346 | this.txt4kResult.Visible = false;
347 | //
348 | // chart1
349 | //
350 | chartArea1.AxisX.Interval = 5D;
351 | chartArea1.AxisX.Maximum = 15D;
352 | chartArea1.AxisX.Minimum = 0D;
353 | chartArea1.AxisX.Title = "时间(s)";
354 | chartArea1.AxisY.Title = "MB/s";
355 | chartArea1.Name = "ChartArea1";
356 | this.chart1.ChartAreas.Add(chartArea1);
357 | this.chart1.Location = new System.Drawing.Point(476, 32);
358 | this.chart1.Name = "chart1";
359 | series1.ChartArea = "ChartArea1";
360 | series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
361 | series1.IsVisibleInLegend = false;
362 | series1.Legend = "Legend1";
363 | series1.Name = "Series1";
364 | this.chart1.Series.Add(series1);
365 | this.chart1.Size = new System.Drawing.Size(322, 440);
366 | this.chart1.TabIndex = 12;
367 | this.chart1.Text = "chart1";
368 | title1.Name = "Title1";
369 | title1.Text = "4K随机写入速度";
370 | this.chart1.Titles.Add(title1);
371 | //
372 | // chartThreads
373 | //
374 | chartArea2.AxisX.Interval = 1D;
375 | chartArea2.AxisX.IsLogarithmic = true;
376 | chartArea2.AxisX.LogarithmBase = 2D;
377 | chartArea2.AxisX.Maximum = 32D;
378 | chartArea2.AxisX.Minimum = 1D;
379 | chartArea2.AxisX.Title = "Threads";
380 | chartArea2.AxisY.Title = "MB/s";
381 | chartArea2.Name = "ChartArea1";
382 | this.chartThreads.ChartAreas.Add(chartArea2);
383 | this.chartThreads.Location = new System.Drawing.Point(830, 32);
384 | this.chartThreads.Name = "chartThreads";
385 | series2.ChartArea = "ChartArea1";
386 | series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
387 | series2.IsVisibleInLegend = false;
388 | series2.Legend = "Legend1";
389 | series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Square;
390 | series2.Name = "Series1";
391 | series2.Points.Add(dataPoint1);
392 | this.chartThreads.Series.Add(series2);
393 | this.chartThreads.Size = new System.Drawing.Size(322, 441);
394 | this.chartThreads.TabIndex = 13;
395 | this.chartThreads.Text = "chart2";
396 | title2.Name = "Title1";
397 | title2.Text = "4K随机写入速度-线程数";
398 | this.chartThreads.Titles.Add(title2);
399 | //
400 | // pictureBox1
401 | //
402 | this.pictureBox1.BackColor = System.Drawing.Color.White;
403 | this.pictureBox1.Cursor = System.Windows.Forms.Cursors.Hand;
404 | this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
405 | this.pictureBox1.ImeMode = System.Windows.Forms.ImeMode.NoControl;
406 | this.pictureBox1.Location = new System.Drawing.Point(476, 434);
407 | this.pictureBox1.Margin = new System.Windows.Forms.Padding(6);
408 | this.pictureBox1.Name = "pictureBox1";
409 | this.pictureBox1.Size = new System.Drawing.Size(119, 39);
410 | this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
411 | this.pictureBox1.TabIndex = 50;
412 | this.pictureBox1.TabStop = false;
413 | this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
414 | //
415 | // pictureBox2
416 | //
417 | this.pictureBox2.BackColor = System.Drawing.Color.White;
418 | this.pictureBox2.Cursor = System.Windows.Forms.Cursors.Hand;
419 | this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
420 | this.pictureBox2.ImeMode = System.Windows.Forms.ImeMode.NoControl;
421 | this.pictureBox2.Location = new System.Drawing.Point(830, 434);
422 | this.pictureBox2.Margin = new System.Windows.Forms.Padding(6);
423 | this.pictureBox2.Name = "pictureBox2";
424 | this.pictureBox2.Size = new System.Drawing.Size(119, 39);
425 | this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
426 | this.pictureBox2.TabIndex = 51;
427 | this.pictureBox2.TabStop = false;
428 | this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);
429 | //
430 | // chartFullSeq
431 | //
432 | chartArea3.AxisX.Minimum = 0D;
433 | chartArea3.AxisX.MinorGrid.Enabled = true;
434 | chartArea3.AxisX.MinorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot;
435 | chartArea3.AxisX.ScaleBreakStyle.CollapsibleSpaceThreshold = 10;
436 | chartArea3.AxisX.Title = "写入量(GB)";
437 | chartArea3.AxisY.Minimum = 0D;
438 | chartArea3.AxisY.MinorGrid.Enabled = true;
439 | chartArea3.AxisY.MinorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot;
440 | chartArea3.AxisY.ScaleBreakStyle.CollapsibleSpaceThreshold = 10;
441 | chartArea3.AxisY.Title = "MB/s";
442 | chartArea3.Name = "ChartArea1";
443 | chartArea3.Position.Auto = false;
444 | chartArea3.Position.Height = 85.65887F;
445 | chartArea3.Position.Width = 98F;
446 | chartArea3.Position.Y = 11.34114F;
447 | this.chartFullSeq.ChartAreas.Add(chartArea3);
448 | this.chartFullSeq.Location = new System.Drawing.Point(28, 479);
449 | this.chartFullSeq.Name = "chartFullSeq";
450 | series3.ChartArea = "ChartArea1";
451 | series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
452 | series3.IsVisibleInLegend = false;
453 | series3.Legend = "Legend1";
454 | series3.MarkerStep = 4;
455 | series3.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Diamond;
456 | series3.Name = "Series1";
457 | series3.XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Int32;
458 | this.chartFullSeq.Series.Add(series3);
459 | this.chartFullSeq.Size = new System.Drawing.Size(1124, 250);
460 | this.chartFullSeq.TabIndex = 52;
461 | this.chartFullSeq.Text = "chart2";
462 | title3.Name = "Title1";
463 | title3.Text = "全盘连续写入";
464 | this.chartFullSeq.Titles.Add(title3);
465 | this.chartFullSeq.Click += new System.EventHandler(this.chartFullSeq_Click);
466 | //
467 | // linkLabel1
468 | //
469 | this.linkLabel1.AutoSize = true;
470 | this.linkLabel1.Location = new System.Drawing.Point(39, 785);
471 | this.linkLabel1.Name = "linkLabel1";
472 | this.linkLabel1.Size = new System.Drawing.Size(79, 20);
473 | this.linkLabel1.TabIndex = 54;
474 | this.linkLabel1.TabStop = true;
475 | this.linkLabel1.Text = "linkLabel1";
476 | this.linkLabel1.Visible = false;
477 | //
478 | // labelSysversion
479 | //
480 | this.labelSysversion.AutoSize = true;
481 | this.labelSysversion.Location = new System.Drawing.Point(51, 32);
482 | this.labelSysversion.Name = "labelSysversion";
483 | this.labelSysversion.Size = new System.Drawing.Size(85, 20);
484 | this.labelSysversion.TabIndex = 1;
485 | this.labelSysversion.Text = "SysVersion";
486 | //
487 | // labelcpu
488 | //
489 | this.labelcpu.AutoSize = true;
490 | this.labelcpu.Location = new System.Drawing.Point(51, 64);
491 | this.labelcpu.Name = "labelcpu";
492 | this.labelcpu.Size = new System.Drawing.Size(38, 20);
493 | this.labelcpu.TabIndex = 2;
494 | this.labelcpu.Text = "CPU";
495 | //
496 | // Form1
497 | // //this.AutoScaleDimensions = new SizeF(1F, 1F);
498 | //this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
499 | //this.AutoScaleDimensions = new System.Drawing.SizeF(92F, 92F);
500 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
501 | this.ClientSize = new System.Drawing.Size(1167, 733);
502 | this.Controls.Add(this.labelcpu);
503 | this.Controls.Add(this.comboBoxDisk);
504 | this.Controls.Add(this.labelSysversion);
505 | this.Controls.Add(this.linkLabel1);
506 | this.Controls.Add(this.chartFullSeq);
507 | this.Controls.Add(this.pictureBox2);
508 | this.Controls.Add(this.pictureBox1);
509 | this.Controls.Add(this.chartThreads);
510 | this.Controls.Add(this.chart1);
511 | this.Controls.Add(this.groupBox2);
512 | this.Controls.Add(this.txt4kResult);
513 | this.Font = new System.Drawing.Font("Microsoft YaHei", 8.1F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
514 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
515 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
516 | this.Margin = new System.Windows.Forms.Padding(6);
517 | this.MaximizeBox = false;
518 | this.Name = "Form1";
519 | this.Text = "WTGBench ";
520 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
521 | this.Load += new System.EventHandler(this.Form1_Load);
522 | this.groupBox2.ResumeLayout(false);
523 | this.groupBox2.PerformLayout();
524 | this.groupBox3.ResumeLayout(false);
525 | this.groupBox3.PerformLayout();
526 | ((System.ComponentModel.ISupportInitialize)(this.pictureBoxL1)).EndInit();
527 | ((System.ComponentModel.ISupportInitialize)(this.pictureBoxL2)).EndInit();
528 | ((System.ComponentModel.ISupportInitialize)(this.pictureBoxL3)).EndInit();
529 | ((System.ComponentModel.ISupportInitialize)(this.pictureBoxL4)).EndInit();
530 | ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
531 | ((System.ComponentModel.ISupportInitialize)(this.chartThreads)).EndInit();
532 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
533 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
534 | ((System.ComponentModel.ISupportInitialize)(this.chartFullSeq)).EndInit();
535 | this.ResumeLayout(false);
536 | this.PerformLayout();
537 |
538 | }
539 |
540 | #endregion
541 | private System.Windows.Forms.GroupBox groupBox2;
542 | private System.Windows.Forms.Button btnStart;
543 | private System.Windows.Forms.GroupBox groupBox3;
544 | private System.Windows.Forms.ProgressBar progressBar1;
545 | private System.Windows.Forms.TextBox txt4kResult;
546 | private System.Windows.Forms.TextBox txtSeqResult;
547 | private System.Windows.Forms.Label label6;
548 | private System.Windows.Forms.TextBox txtA4kResult;
549 | private System.Windows.Forms.Label label5;
550 | private System.Windows.Forms.Label label7;
551 | private System.Windows.Forms.Label labelLevel;
552 | private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
553 | private System.Windows.Forms.CheckBox checkBoxScenario;
554 | private System.Windows.Forms.DataVisualization.Charting.Chart chartThreads;
555 | private System.Windows.Forms.CheckBox checkBoxThread;
556 | private System.Windows.Forms.PictureBox pictureBox1;
557 | private System.Windows.Forms.PictureBox pictureBox2;
558 | private System.Windows.Forms.CheckBox checkBoxFast;
559 | private System.Windows.Forms.CheckBox checkBoxFullSeq;
560 | private System.Windows.Forms.DataVisualization.Charting.Chart chartFullSeq;
561 | private System.Windows.Forms.Label labelSceRes;
562 | private System.Windows.Forms.Label label1;
563 | private System.Windows.Forms.ComboBox comboBoxDisk;
564 | private System.Windows.Forms.ToolTip toolTip1;
565 | private System.Windows.Forms.LinkLabel linkLabel1;
566 | private System.Windows.Forms.Label labelSysversion;
567 | private System.Windows.Forms.Label labelcpu;
568 | private System.Windows.Forms.PictureBox pictureBoxL1;
569 | private System.Windows.Forms.PictureBox pictureBoxL2;
570 | private System.Windows.Forms.PictureBox pictureBoxL3;
571 | private System.Windows.Forms.PictureBox pictureBoxL4;
572 | }
573 | }
574 |
575 |
--------------------------------------------------------------------------------