How can I test the disk write speed ?, Test disk speed

Source: Internet
Author: User

How can I test the disk write speed ?, Test disk speed
How can I test the disk write speed?

1. Problem Source: an emergency connection problem occurs in a business trip project: test the disk write speed?
The docking program needs to regularly store results data to the disk, but you do not know:
1) How much Buffer will be written to the disk faster?
2) Can the write speed of a disk reach the maximum nominal value of the disk array vendor?

2. Based on the above two questions, how can I test the disk write speed?
The problem is further detailed:
1) speed = write size/Write interval, that is, yesKey ContentTest the size of data written within a certain interval.
2) set different sizes for each write: 512 k, 1 M, 2 M, 5 M, 10 M, 20 M, 50 M, 100 M, 200 M, 300 M .....
Write cyclically for-10 times to see which Buffer is the fastest written.

3. knowledge points:
1) the maximum size of stack memory can be opened up. Vs2010 is 1 M-2 M. An error is prompted during the test.
2) the maximum size of heap memory that can be opened up is determined by the memory and virtual memory. The maximum size of a 32-bit system is 2 GB, but it runs with the current system.
Other program conditions are related to the virtual memory size. Test results show that the 32-bit win7 system crashes after writing about MB of heap memory for 10 consecutive times.

4. Related Knowledge Point textbook explanation:
STACK: in Windows, a stack is a continuous memory area that expands the data structure to a low address. This statement indicates that the top stack address and maximum stack capacity are pre-defined by the system,
In WINDOWS, the stack size is 2 M (OR 1 M, in short, a constant is determined during compilation). If the requested space exceeds the remaining space of the stack, overflow is displayed. Therefore, the space available from the stack is small.
Heap: the heap expands the data structure to the high address, and is a non-sequential memory area. This is because the system uses a linked list to store idle memory addresses, which is naturally discontinuous, And the traversal direction of the linked list is from low address to high address.
The heap size is limited by the valid virtual memory in the computer system. It can be seen that the heap space is flexible and large.

5. The program implementation is as follows (very simple and not explained ):

// WriteFileDemo. cpp: defines the entry point of the console application. // # Include "stdafx. h "# include <iostream >#include <fstream> using namespace std; # include <windows. h> # include <WinBase. h> # include <ctime> // The target Write File const char * g_psOutFile = "D: \ test_file \ 1.txt "; // Buffer size const long WRITE_BUFF_SIZE = 10*1024*1024; // MB bytes // write count # define MAX_WRITE_CNT 5 // each buffer byte is initialized to the 'A' character void initBuf (char * pszBuf, int iCnt) {for (int I = 0; I <iCnt; ++ I) {pszBuf [I] = 97 ;}// write cyclically Input File void writeFileFun (char * szBuf) {ofstream ofout (g_psOutFile); int I = 0; while (I <MAX_WRITE_CNT) {ofout <szBuf <endl; + + I ;}/// test the disk write speed void writeFileTestFun () {// heap memory application. Obviously, the stack memory is not suitable for char * szTenMBBuf = (char *) malloc (WRITE_BUFF_SIZE); (void) initBuf (bytes, WRITE_BUFF_SIZE); size_t nBeginTicks = GetTickCount (); cout <"BeginTime =" <nBeginTicks <endl; (void) writeFileFun (szTenMBBuf); size _ T nEndTicks = GetTickCount (); cout <"EndTime =" <nEndTicks <endl; size_t nSpan = nEndTicks-nBeginTicks; cout <"nSpanTime =" <nSpan <"ms" <endl; // ms float nTotalBytes = WRITE_BUFF_SIZE * MAX_WRITE_CNT; // total number of written bytes float nTotalTimes = (float) (nSpan)/1000.0f; // total time consumed, in the unit of s cout <"nTotalWriteBytes =" <nTotalBytes <endl; cout <"nTotalTimes =" <nTotalTimes <endl; float fSpee D = nTotalBytes/nTotalTimes; cout <"Speed =" <fSpeed <"Byte/s" <endl; // write Speed Byte/s cout <"Speed =" <fSpeed/1024366f/1024366f <"MB/s" <endl; // write speed MByte/s if (NULL! = SzTenMBBuf) {free (szTenMBBuf); szTenMBBuf = NULL;} int _ tmain (int argc, _ TCHAR * argv []) {(void) writeFileTestFun (); return 0 ;}

GreenTree Inn near Pingxi wangfu, Changping District, Beijing, stayed up late.

Author: Mingyi Tianxia
Reprinted please indicate the source, original address: http://blog.csdn.net/laoyang360/article/details/46321891
If this article is helpful to you, click 'ding' to support it. Your support is the greatest motivation for my persistence in writing. Thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.