Profiling and performace testing

PerformanceCounter
Class PerformanceCounter allows to mesure execution time of some code part. It uses gettimeofday Linux system call for getting start (when PerformanceCounter object was created) and stop time (when PerformanceCounter object was destroyed). Difference between this times are written to syslog with presetted text (setted in PerformanceCounter constructor).

Platform request processing methods (DbSession), DB syncronisation (UpdateThread) and DB interaction (QueryExecutor) already use this class for reporting about method`s execution time.

Example
This example shows how to use PerformanceCounter for time mesurment of QueryExecutor::doesTmpUserExist:

bool QueryExecutor::doesTmpUserExist(const QSharedPointer &user){ PerformanceCounter counter("QueryExecutor::doesTmpUserExist"); QSqlQuery query(m_database); query.prepare("select * from signups where login = :login or email = :email;"); query.bindValue(":login",user->getLogin); query.bindValue(":email",user->getEmail); syslog(LOG_INFO,"Selecting: %s", query.lastQuery.toStdString.c_str); query.exec; if (query.next) { return true; } else { syslog(LOG_INFO,"No matching users."); return false; } }

Performance testing
All scripts described below can be used without arguments - in this case default values used.

src/profiler/
profiler provide interface for multiple sending of writeTag, login and loadTags requests. User can specify request parameters and number of reqeusts. Command syntax:

Where number_of_iterations is a number of performed requests in case of loadTags and login requests, and number of tags added in case of writeTag. If number_of_iterations is set to -1 than programm will perform requests till termination. Before using, profiler should be compiled using:

during execution profiler gives information about each request to stdout :

where request_number is number of performed request or number of added tags in case of writeTag request; time is a time of request in milliseconds, error_flag - 0 means no error, 1 = error.

src/profiler/scripts/profile*

 * 1) profileAddChannel performs N addChannel requests with configurable auth_token. Usage: "profileAddChannel N auth_token"
 * 2) profileAddDeleteUser performs N addUser and deleteUser requests. Usage: "profileAddDeleteUser N".
 * 3) profileRegisterUser performs N registerUser requests. Usage: "profileRegisterUser N".
 * 4) profileSubscribeUnsubscribe performs N subscribe and unsubscribe requests with predefined auth_token. Usage: "profileSubscribeUnsubscribe N auth_token".
 * 5) profileWriteTag performs N writeTag requests with predefined auth_token. Usage: "profileWriteTag N auth_token".

This scripts dont provide any useful output.

src/profiler/scripts/testWriteTag
testWriteTag script mesure dependence between writeTag request time and number of added tags(into platform). Usage:

where steps_count - number of points for number of added tags variable, step_size - how many tags will be added between two poits, tag_to_be_written how many tags will be added at all points.

Script creates results_w_$date_/ dir where files for each point of number of added tags variable stored. Each file is a log of profiler work - table with tag_to_be_written records and four columns (number of request, time in msecs, error(1 is error, 0 no error), intesity of request).

src/profiler/scripts/testLoadTags
testLoadTags script mesure dependence between loadTags request time and number of added tags(into platform). Usage:

where steps_count - number of points for number of added tags variable, step_size - how many tags will be added between two poits, read_requests_count how many loadTags requests will be performed.

Script creates results_r_$date_/ dir where files for each point of number of added tags variable stored. Each file is a log of profiler work - table with read_requests_count records and four columns (number of request, time in msecs, error(1 is error, 0 no error), intesity of request).

src/profiler/scripts/testMemory
testMemory script mesure dependence between allocated for platform memory and number of added tags(into platform). Script use ps command for time mesurment. Usage:

where steps_count - number of points for number of added tags variable, step_size - how many tags will be added between two poits.

Script creates results_w_$date_/ dir with one file - MemoryUsage. This file conains of two collumns - vsz and rss values for each point of number of added tags variable.