| | @@ -653,18 +653,31 @@ |
| 653 | 653 | |
| 654 | 654 | /* Return the current wall-clock time in microseconds since the |
| 655 | 655 | ** Unix epoch (1970-01-01T00:00:00Z) |
| 656 | 656 | */ |
| 657 | 657 | static sqlite3_int64 timeOfDay(void){ |
| 658 | | -#if defined(_WIN32) |
| 658 | +#if defined(_WIN64) |
| 659 | 659 | sqlite3_uint64 t; |
| 660 | 660 | FILETIME tm; |
| 661 | 661 | GetSystemTimePreciseAsFileTime(&tm); |
| 662 | 662 | t = ((u64)tm.dwHighDateTime<<32) | (u64)tm.dwLowDateTime; |
| 663 | 663 | t += 116444736000000000LL; |
| 664 | 664 | t /= 10; |
| 665 | 665 | return t; |
| 666 | +#elif defined(_WIN32) |
| 667 | + static sqlite3_vfs *clockVfs = 0; |
| 668 | + sqlite3_int64 t; |
| 669 | + if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0); |
| 670 | + if( clockVfs==0 ) return 0; /* Never actually happens */ |
| 671 | + if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){ |
| 672 | + clockVfs->xCurrentTimeInt64(clockVfs, &t); |
| 673 | + }else{ |
| 674 | + double r; |
| 675 | + clockVfs->xCurrentTime(clockVfs, &r); |
| 676 | + t = (sqlite3_int64)(r*86400000.0); |
| 677 | + } |
| 678 | + return t*1000; |
| 666 | 679 | #else |
| 667 | 680 | struct timeval sNow; |
| 668 | 681 | (void)gettimeofday(&sNow,0); |
| 669 | 682 | return ((i64)sNow.tv_sec)*1000000 + sNow.tv_usec; |
| 670 | 683 | #endif |
| | @@ -710,11 +723,11 @@ |
| 710 | 723 | static void endTimer(FILE *out){ |
| 711 | 724 | if( enableTimer ){ |
| 712 | 725 | sqlite3_int64 iEnd = timeOfDay(); |
| 713 | 726 | struct rusage sEnd; |
| 714 | 727 | getrusage(RUSAGE_SELF, &sEnd); |
| 715 | | - sqlite3_fprintf(out, "Run Time: real %.6f user %f sys %f\n", |
| 728 | + sqlite3_fprintf(out, "Run Time: real %.6f user %.6f sys %.6f\n", |
| 716 | 729 | (iEnd - iBegin)*0.000001, |
| 717 | 730 | timeDiff(&sBegin.ru_utime, &sEnd.ru_utime), |
| 718 | 731 | timeDiff(&sBegin.ru_stime, &sEnd.ru_stime)); |
| 719 | 732 | } |
| 720 | 733 | } |
| | @@ -789,14 +802,23 @@ |
| 789 | 802 | static void endTimer(FILE *out){ |
| 790 | 803 | if( enableTimer && getProcessTimesAddr){ |
| 791 | 804 | FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd; |
| 792 | 805 | sqlite3_int64 ftWallEnd = timeOfDay(); |
| 793 | 806 | getProcessTimesAddr(hProcess,&ftCreation,&ftExit,&ftKernelEnd,&ftUserEnd); |
| 807 | +#ifdef _WIN64 |
| 808 | + /* microsecond precision on 64-bit windows */ |
| 794 | 809 | sqlite3_fprintf(out, "Run Time: real %.6f user %f sys %f\n", |
| 795 | 810 | (ftWallEnd - ftWallBegin)*0.000001, |
| 796 | 811 | timeDiff(&ftUserBegin, &ftUserEnd), |
| 797 | 812 | timeDiff(&ftKernelBegin, &ftKernelEnd)); |
| 813 | +#else |
| 814 | + /* millisecond precisino on 32-bit windows */ |
| 815 | + sqlite3_fprintf(out, "Run Time: real %.3f user %.3f sys %.3f\n", |
| 816 | + (ftWallEnd - ftWallBegin)*0.000001, |
| 817 | + timeDiff(&ftUserBegin, &ftUserEnd), |
| 818 | + timeDiff(&ftKernelBegin, &ftKernelEnd)); |
| 819 | +#endif |
| 798 | 820 | } |
| 799 | 821 | } |
| 800 | 822 | |
| 801 | 823 | #define BEGIN_TIMER beginTimer() |
| 802 | 824 | #define END_TIMER(X) endTimer(X) |
| 803 | 825 | |