Ignore:
Timestamp:
Dec 24, 2010, 2:22:30 AM (11 years ago)
Author:
schwittmann
Message:

External Client: added more statistics

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/KeySearcher/ExternalClient/Cryptool.cpp

    r2256 r2258  
    1616
    1717#include "Cryptool.h"
     18
     19unsigned long DiffMicSec(timeval & start, timeval & end)
     20{
     21    return (end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec);
     22}
    1823
    1924Cryptool::Cryptool()
     
    101106   
    102107    localCosts = new float[subbatch];
    103     lastSubbatchCompleted = clock();
     108
     109    gettimeofday(&lastSubbatchCompleted, NULL);
    104110
    105111    // required for thousand/million separator in printf
     
    160166JobResult Cryptool::doOpenCLJob(const Job& j)
    161167{
     168    res.Guid = j.Guid;
    162169    cl_int err;
    163170
     
    201208void Cryptool::enqueueSubbatch(cl::CommandQueue& queue, cl::Buffer& keybuffer, cl::Buffer& costs, int add, int length, const Job& j)
    202209{
     210    timeval openCLStart;
     211    gettimeofday(&openCLStart, NULL);
    203212        cl_int err;
    204213
     
    241250                throw new std::exception();
    242251        }
     252
     253    timeval openCLEnd;
     254    gettimeofday(&openCLEnd, NULL);
    243255#ifdef _OPENMP
    244256#pragma omp parallel
     
    280292        }
    281293#endif
     294
     295    timeval finishedSubbatch;
     296    gettimeofday(&finishedSubbatch, NULL);
     297
     298    unsigned long totalMic= DiffMicSec(openCLStart, finishedSubbatch);
     299
     300    printf("Completed a subbatch in %.3f seconds. %.2f%% spent on OpenCL, %.2f%% on sorting.\n",
     301            (float)totalMic/1000000, DiffMicSec(openCLStart, openCLEnd)/(float)totalMic*100, DiffMicSec(openCLEnd, finishedSubbatch)/(float)totalMic*100);
     302
    282303}
    283304
     
    288309        enqueueSubbatch(queue, keybuffer, costs, i*subbatch, subbatch, j);
    289310
    290         clock_t now = clock();
    291         clock_t timeDiff = now - lastSubbatchCompleted;
     311        timeval now;
     312        gettimeofday(&now, NULL);
     313        unsigned long timeDiffMicroSec = (now.tv_sec - lastSubbatchCompleted.tv_sec)*1000000 + (now.tv_usec - lastSubbatchCompleted.tv_usec);
    292314        lastSubbatchCompleted = now;
    293         printf("% .2f%% done. %'u keys/sec\n", ((i+1)*subbatch)/(float)size*100, (unsigned int)(subbatch/(timeDiff/(float)CLOCKS_PER_SEC)));
     315        printf("% .2f%% done. %'u keys/sec\n", ((i+1)*subbatch)/(float)size*100, (unsigned int)(subbatch/((float)timeDiffMicroSec/1000000)));
    294316    }
    295317
Note: See TracChangeset for help on using the changeset viewer.