Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ C ++ precision performance test function     - Oracle Client + PL SQL Developer enables remote access to the Oracle database (Database)

- How to restart after a crash Cinnamon (Linux)

- Enterprise Hadoop cluster architecture - Hadoop installation (Server)

- Based AutoYaST automated installation of SUSE practice (Linux)

- Linux startup and logon security settings (Linux)

- Ubuntu uses under KVM + Qemu virtual machine build (Linux)

- How to convert images, audio and video formats on Ubuntu (Linux)

- NET Developers need to know some Linux commands (Linux)

- How to troubleshoot Windows and Ubuntu dual system time is not synchronized (Linux)

- Oracle capability i / o (stress test database server i / o performance) (Database)

- MongoDB polymerization being given (Database)

- Docker in the development and practice of IFTTT (Server)

- MongoDB 3.2 to upgrade from 3.0.7 (Database)

- ThinkPad X201i installation notes Debian 7.5 (Linux)

- Linux Basics Tutorial: Combining awk delete data before the specified date hdfs (Linux)

- How to properly set up a Linux swap partition (Linux)

- Installation and Configuration rsync server under CentOS 6.3 (Server)

- Linux environment password security settings (Linux)

- Getting Started Linux Shell Scripting (Programming)

- Linux host system monitoring implement the cgi (Server)

 
         
  C ++ precision performance test function
     
  Add Date : 2018-11-21      
         
       
         
  In the actual software development work, we often test the efficiency of a module or function. Or is the time complexity of an algorithm (although the time depends on the complexity of the machine performance to some extent, but on the same computer, through algorithm optimization, you can test its complexity); this time you need to get the exact time, we can accurate running time, the following function to achieve a precise timing, timing accuracy can reach microsecond; can be used to test the efficiency of a module!

// Purpose: this programme is designed for testing the performance of your code, some function ect,
// It can show the time of spending on your running on it. It is beneficial to improve your performance
// Of code

#include < Windows.h>
#include < iostream>
#include < tchar.h>
using namespace std;
#define IN

#ifdef _DEBUG
#define _Trace_Size 500
inline void FileTrace (IN LPCTSTR szFormat, ...)
{
 if (szFormat == NULL)
  return;

 TCHAR t_trace [_Trace_Size] = {_T ( '\ 0')};
 va_list vl = NULL;

 // Generated Content
 va_start (vl, szFormat);
 _vsntprintf_s (t_trace, _Trace_Size, _TRUNCATE, szFormat, vl);
 va_end (vl);
 OutputDebugString (t_trace);
}
#else
inline void FileTrace (IN LPCTSTR szFormat, ...) {}
#endif

LARGE_INTEGER begin_time, freq;

int main ()
{
 LARGE_INTEGER begin_time, freq;
 QueryPerformanceFrequency (& freq);
 QueryPerformanceCounter (& begin_time);
    // Begin time
    for (long test0 = 0; test0 < 5000000; test0 ++)
    {
  test0 = test0 + 1;
    }
 LARGE_INTEGER end_time0;

  QueryPerformanceCounter (& end_time0);
 // After runnin the 'for' loop statement, the time is Time0
  double Time0 = ((double) (end_time0.QuadPart - begin_time.QuadPart) * 1000.0) / (double) (freq.QuadPart);

    int test1 = 10000;
 while (test1)
 {
  test1--;
 }
  LARGE_INTEGER end_time1;
 QueryPerformanceCounter (& end_time1);
  double Time1 = ((double) (end_time1.QuadPart - begin_time.QuadPart) * 1000.0) / (double) (freq.QuadPart);
    FileTrace (_T ( "********************************************* ************************************ \ n "));
 FileTrace (_T ( "Test result is as follow: \ ntime:% I64x,% .3fms,% .3fms \ n"), (ULONGLONG) 0, Time0, Time1);
 FileTrace (_T ( "********************************************* ************************************ \ n "));
    system ( "pause");
 return 0;
}
     
         
       
         
  More:      
 
- CentOS 6 compiling httpd-2.4.10 (Server)
- Nodejs nano library to handle couchdb: need a timeout (Database)
- Linux ./configure --prefix command (Linux)
- Python common data type summary (Programming)
- Linux Detailed instructions alias settings (Linux)
- Linux system boot process detail (Linux)
- Ubuntu Linux Change the PATH (Linux)
- Use Aptik Battery Monitor monitoring Ubuntu laptop battery usage (Linux)
- Hazelcast integration with MongoDB (Database)
- Linux Routine Task Scheduler (Linux)
- Detailed reference Oracle 11g Partition (Database)
- Linux System Getting Started Learning: DeVeDe installed on Linux to create a video DVD (Linux)
- Java string intern constant pool resolution Introduction (Programming)
- You need to know 12 Git High Command (Linux)
- Linux Network Programming - raw socket instance: MAC Address Scanner (Programming)
- Compiling source code Nginx module installation subs_filter (Server)
- To install Jetty server configuration in detail (Server)
- Hardware Firewall Basics (Linux)
- Use $ BASH ENV variable to mention the right way under Linux (Linux)
- Install Ubuntu open source drawing program MyPaint 1.2.0 (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.