Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7666171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:46:00+00:00 2026-05-31T14:46:00+00:00

I have a SSD and I am trying to use it to simulate my

  • 0

I have a SSD and I am trying to use it to simulate my program I/O performance, however, IOPS calculated from my program is much much faster than IOMeter.

My SSD is PLEXTOR PX-128M3S, by IOMeter, its max 512B random read IOPS is around 94k (queue depth is 32).
However my program (32 windows threads) can reach around 500k 512B IOPS, around 5 times of IOMeter! I did data validation but didn’t find any error in data fetching. It’s because my data fetching in order?

I paste my code belwo (it mainly fetch 512B from file and release it; I did use 4bytes (an int) to validate program logic and didn’t find problem), can anybody help me figure out where I am wrong?

Thanks so much in advance!!

    #include <stdio.h>
    #include <Windows.h>



    //Global variables
    long completeIOs = 0; 
    long completeBytes = 0;
    int  threadCount = 32;
    unsigned long long length = 1073741824;                  //4G test file

    int interval = 1024;

    int resultArrayLen = 320000;

    int *result = new int[resultArrayLen];

    //Method declarison
    double GetSecs(void);                              //Calculate out duration
    int InitPool(long long,char*,int);                    //Initialize test data for testing, if successful, return 1; otherwise, return a non 1 value. 
    int * FileRead(char * path);
    unsigned int DataVerification(int*, int sampleItem);                         //Verify data fetched from pool

    int main()
    {
        int sampleItem = 0x1;
        char * fPath = "G:\\workspace\\4G.bin";
        unsigned int invalidIO = 0;

        if (InitPool(length,fPath,sampleItem)!= 1)
           printf("File write err... \n");

        //start do random I/Os from initialized file
        double start = GetSecs();

        int * fetchResult = FileRead(fPath);

        double end = GetSecs();

        printf("File read IOPS is %.4f per second.. \n",completeIOs/(end - start));

        //start data validation, for 4 bytes fetch only

    //  invalidIO = DataVerification(fetchResult,sampleItem);

    //  if (invalidIO !=0)
    //  {
    //      printf("Total invalid data fetch IOs are %d", invalidIO);
    //  }

        return 0;
    }



    int InitPool(long long length, char* path, int sample)
    {
        printf("Start initializing test data ... \n");

        FILE * fp = fopen(path,"wb");

        if (fp == NULL)
        {
            printf("file open err... \n");
            exit (-1);
        }

        else                                    //initialize file for testing
        {
            fseek(fp,0L,SEEK_SET);

            for (int i=0; i<length; i++)
            {
                fwrite(&sample,sizeof(int),1,fp);
            }

            fclose(fp);

            fp = NULL;

            printf("Data initialization is complete...\n");

            return 1;

        }
    }

    double GetSecs(void)

    {
        LARGE_INTEGER frequency;
        LARGE_INTEGER start;

        if(! QueryPerformanceFrequency(&frequency)) 
            printf("QueryPerformanceFrequency Failed\n");

        if(! QueryPerformanceCounter(&start))
            printf("QueryPerformanceCounter Failed\n");

        return ((double)start.QuadPart/(double)frequency.QuadPart);

    }

    class input
    {
    public:
        char *path;
        int starting;

        input (int st, char * filePath):starting(st),path(filePath){}

    };

    //Workers
    DWORD WINAPI FileReadThreadEntry(LPVOID lpThreadParameter)
    {
        input * in = (input*) lpThreadParameter; 

        char* path = in->path;

        FILE * fp = fopen(path,"rb");

        int sPos = in->starting;

    //  int * result = in->r;

        if(fp != NULL)
        {
            fpos_t pos;
            for (int i=0; i<resultArrayLen/threadCount;i++)
            {

                pos = i * interval;
                fsetpos(fp,&pos);
                //For 512 bytes fetch each time
                unsigned char *c =new unsigned char [512];
                if (fread(c,512,1,fp) ==1)
                {
                    InterlockedIncrement(&completeIOs);
                    delete c;
                }

                //For 4 bytes fetch each time
                /*if (fread(&result[sPos + i],sizeof(int),1,fp) ==1)
                {
                    InterlockedIncrement(&completeIOs);
                }*/

                else
                {
                    printf("file read err...\n");
                    exit(-1);
                }
            }

            fclose(fp);
            fp = NULL;
            }

        else
        {
            printf("File open err... \n");
            exit(-1);
        }
    }

    int * FileRead(char * p)
    {
        printf("Starting reading file ... \n");


        HANDLE mWorkThread[256];                      //max 256 threads
        completeIOs = 0;

        int slice = int (resultArrayLen/threadCount);

        for(int i = 0; i < threadCount; i++)
        {
            mWorkThread[i] = CreateThread(
                        NULL,
                        0,
                        FileReadThreadEntry,
                        (LPVOID)(new input(i*slice,p)),
                        0, 
                        NULL);
        }

       WaitForMultipleObjects(threadCount, mWorkThread, TRUE, INFINITE);

       printf("File read complete... \n");

       return result;

    }

    unsigned int DataVerification(int* result, int sampleItem)
    {
        unsigned int invalid = 0;
        for (int i=0; i< resultArrayLen/interval;i++)
        {
            if (result[i]!=sampleItem)
            {
                invalid ++;
                continue;
            }
        }

        return invalid;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:46:02+00:00Added an answer on May 31, 2026 at 2:46 pm

    I didn’t look in enough detail to be certain, but I didn’t see any code there to flush the data to the disk and/or ensure your reads actually came from the disk. That being the case, it appears that what you’re measuring is primarily the performance of the operating system’s disk caching. While the disk might contribute a little to the performance you’re measuring, it’s probably only a small contributor, with other factors dominating.

    Since the code is apparently written for Windows, you might consider (for one example) opening the file with CreateFile, and passing the FILE_FLAG_NO_BUFFERING flag when you do so. This will (at least mostly) remove the operating system cache from the equation, and force each read or write to deal directly with the disk itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SSD as system drive (C:) and it's a real lifesaver, however
I have file with contents in list form such as [1,'ab','fgf','ssd'] [2,'eb','ghf','hhsd'] [3,'ag','rtf','ssfdd'] I
We have a v.large Dictionary<long,uint> (several million entries) as part of a high performance
I have been interested in SSD drives for quite sometime. I do a lot
I have a MySQL query (Ubu 10.04,Innodb, Core i7, 16Gb RAM, SSD drives, MySQL
I have a thread pool writing data to an SSD disk. (windows XP, c#)
Have an app that can use tts to read text messages. It can also
I have a simple one-project solution in C++. From the IDE I click on
I have a question about Symfony2 performance. I have been developing with Symfony2 under
I have a new 256 gig SSD drive which replaced my MacBook Pro's CD

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.