Linux ? Windows?? ???? ? ??? ?? ??? ???? ??
????? CPU? ??? ?? ??? ???? ?? ?????. ?? ???? ??. x86 ? x86_64 ????? ?? ???? Linux ? Windows?? ?? ???? ??? ??? ????.
?? ?? ? ??? ?? ??
???? ??? CPU ??? ????? ?? ? ???? ? ??? ??? ??? ????? ?? ??? ?????.
int startcputime, endcputime, wcts, wcte; startcputime = cputime(); function(args); endcputime = cputime(); std::cout << "it took " << endcputime - startcputime << " s of CPU to execute this\n"; wcts = wallclocktime(); function(args); wcte = wallclocktime(); std::cout << "it took " << wcte - wcts << " s of real time to execute this\n";
??? ??? ????
??? ?? ?? ?? ??? ???? ??????. , ?? ??? ???? ?????? ???? ??? ??? ??? ? ??? ?????.
??
??? C? C ???? Windows ? Linux?? ???? ??? ??????.
// Windows #ifdef _WIN32 #include <Windows.h> double get_wall_time(){ LARGE_INTEGER time, freq; if (!QueryPerformanceFrequency(&freq)){ // Handle error return 0; } if (!QueryPerformanceCounter(&time)){ // Handle error return 0; } return (double)time.QuadPart / freq.QuadPart; } double get_cpu_time(){ FILETIME a, b, c, d; if (GetProcessTimes(GetCurrentProcess(), &a, &b, &c, &d) != 0){ // Returns total user time. // Can be tweaked to include kernel times as well. return (double)(d.dwLowDateTime | ((unsigned long long)d.dwHighDateTime << 32)) * 0.0000001; }else{ // Handle error return 0; } } // Linux #else #include <time.h> #include <sys/time.h> double get_wall_time(){ struct timeval time; if (gettimeofday(&time, NULL)){ // Handle error return 0; } return (double)time.tv_sec + (double)time.tv_usec * .000001; } double get_cpu_time(){ return (double)clock() / CLOCKS_PER_SEC; } #endif
?? ??? ??:
-
Windows:
- ? ??: ?? ???
- CPU ??: GetProcessTimes()
-
Linux:
- ? ??: gettimeofday()
- CPU ??: clock()
??
??? ??? ???? ??? ????.
#include <math.h> #include <iostream> using namespace std; int main(){ // Start Timers double wall0 = get_wall_time(); double cpu0 = get_cpu_time(); // Computational task (e.g., numerical summation). double sum = 0; #pragma omp parallel for reduction(+ : sum) for (long long i = 1; i < 10000000000; i++){ sum += log((double)i); } // Stop timers double wall1 = get_wall_time(); double cpu1 = get_cpu_time(); cout << "Wall Time = " << wall1 - wall0 << endl; cout << "CPU Time = " << cpu1 - cpu0 << endl; // Prevent code elimination (optimization). cout << endl; cout << "Sum = " << sum << endl; }
? ?? ??? ?? ?? ?? ???? CPU ??? ?????.
? ??? Linux ? Windows?? ???? ? ??? ?? ??? ???? ??? ??????? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











?, ?? ???? C? ??? ??, ?? ??? ? ??????. 1. ?? ???? ??? ??? ?? ?? ??? ?? ?? ??? ?????. 2. ????? ??? ?? ??? ?? ??? ??? ?? ? ??? ?????. 3. ??? ???? ?? ?? ???? ???? ?? ?? ??? ??? ????? ????? ???? ?????.

C? ? ?? ?? ??? ??? ??? : ??? ?? ??? ? ??? ???. 1. ??? ?? ???? ?? ??? ? ???? ?? ????? ?? ??? ????? ?? ???? ??? ? ????. 2. ??? ???? ?? ?? ? ??? ?? ???? ???? ??? ?? ?? ??? ?????.

?, C? ???? ?? ?????. 1) ??? ??? ?? ?? ? ??? ???? ?????. 2) ?? ???? ???? ??? ????. 3) ?? ??? ????? ??? ?? ???? ??? ??? ? ??????. ?? ? ??? ?? ???? ???? ??? ?????? ??? ?? ?????.

C DestructorsCanleadToSeVeralCommonerrors.toaVoidthem : 1) ?? ?? ?? ?? ?? ?? ???

C? ???? ??? ??? ? ??? ?? ????? ????. 1. ??? ???? ?? ??? ?? ????? ???? ??? ??? ???? ?? ? ? ????. 2. ??? ?? ???? ?? ??? ? ???? ?? ????, ??? ???? ?????.

?? ???? ??? C?? ??? ??? ???? ??? : ? ????? ? ? ????? C? ??? ? ????? ?? ?? ??? ?? ??? ???? ?????. 1. ?? ??? ???? C? ?? ??? ???? ?? ?? ?? Curly Braces {}? ???? ?? ??? ?? ??? ???????. 2. ?? ??? ? ??? ?? ???? C?? ?? ??? ?? ????? ??? ???? ???? ???? ??? ?????? ???????. RAII ??? ?? ??? ??? ? ????. 3. ?? ? ??? ???? C? ?? ?, ??? ? ???? ?? ??? ??????? ??? ???? ?? ?? ??? ???????. 4. ?? ????? ???? STL? ??? ????? ????? ????? ???? ????? ????? ???????. 5

C polymorphismincludescompile time, ??? ? Templatepolymorphism.1) compile-timepolymorphismusesfunctionandoveroveroverforlogy

C polymorphismisuniqueduetoitscompikeofile-timeandruntimepolymorphism, forbothefficiency andfoxible.toharnesspowertylogly : 1) audesMartPointerSlikestd :: Quanior_PtrformemoryManagement, 2) ?? baseclasseshavevirtuctors, 3) ??
