Exemplo n.º 1
0
void workerThread() {
    bool r = options["r"].trueValue();
    bool w = options["w"].trueValue();
    long long su = options["sleepMicros"].numberLong();
    Aligned a;
    while( 1 ) { 
        unsigned long long rofs = (rrand() * PG) % len;
        unsigned long long wofs = (rrand() * PG) % len;
        if( mmf ) { 
            if( r ) {
                dummy += mmf[rofs];
                iops++;
            }
            if( w ) {
                mmf[wofs] = 3;
                iops++;
            }
        }
        else {
            if( r ) {
                lf->readAt(rofs, a.addr(), PG);
                iops++;
            }
            if( w ) {
                lf->writeAt(wofs, a.addr(), PG);
                iops++;
            }
        }
        long long micros = su / nThreadsRunning;
        if( micros ) {
            sleepmicros(micros);
        }
    }
}
Exemplo n.º 2
0
void workerThread() {
    bool r = options["r"].trueValue();
    bool w = options["w"].trueValue();
    cout << "read:" << r << " write:" << w << endl;
    long long su = options["sleepMicros"].numberLong();
    Aligned a;
    while( 1 ) { 
        unsigned long long rofs = (rrand() * PG) % len;
        unsigned long long wofs = (rrand() * PG) % len;
        const unsigned P = PG/1024;
        if( mmf ) { 
            if( r ) {
                for( unsigned p = P; p <= recSizeKB; p += P ) {
                    if( rofs < len ) 
                        dummy += mmf[rofs];
                    rofs += PG;
                }
                iops++;
            }
            if( w ) {
                for( unsigned p = P; p <= recSizeKB; p += P ) {
                    if( rofs < len ) 
                        mmf[wofs] = 3;
                    wofs += PG;
                }
                iops++;
            }
        }
        else {
            if( r ) {
                lf->readAt(rofs, a.addr(), recSizeKB * 1024);
                iops++;
            }
            if( w ) {
                lf->writeAt(wofs, a.addr(), recSizeKB * 1024);
                iops++;
            }
        }
        long long micros = su / nThreadsRunning;
        if( micros ) {
            sleepmicros(micros);
        }
    }
}