| | @@ -1749,47 +1749,10 @@ |
| 1749 | 1749 | { 0, 0 } |
| 1750 | 1750 | }; |
| 1751 | 1751 | return Th_CallSubCommand(interp, p, argc, argv, argl, aSub); |
| 1752 | 1752 | } |
| 1753 | 1753 | |
| 1754 | | -#ifdef _WIN32 |
| 1755 | | -# include <windows.h> |
| 1756 | | -#else |
| 1757 | | -# include <sys/time.h> |
| 1758 | | -# include <sys/resource.h> |
| 1759 | | -#endif |
| 1760 | | - |
| 1761 | | -/* |
| 1762 | | -** Get user and kernel times in microseconds. |
| 1763 | | -*/ |
| 1764 | | -static void getCpuTimes(sqlite3_uint64 *piUser, sqlite3_uint64 *piKernel){ |
| 1765 | | -#ifdef _WIN32 |
| 1766 | | - FILETIME not_used; |
| 1767 | | - FILETIME kernel_time; |
| 1768 | | - FILETIME user_time; |
| 1769 | | - GetProcessTimes(GetCurrentProcess(), ¬_used, ¬_used, |
| 1770 | | - &kernel_time, &user_time); |
| 1771 | | - if( piUser ){ |
| 1772 | | - *piUser = ((((sqlite3_uint64)user_time.dwHighDateTime)<<32) + |
| 1773 | | - (sqlite3_uint64)user_time.dwLowDateTime + 5)/10; |
| 1774 | | - } |
| 1775 | | - if( piKernel ){ |
| 1776 | | - *piKernel = ((((sqlite3_uint64)kernel_time.dwHighDateTime)<<32) + |
| 1777 | | - (sqlite3_uint64)kernel_time.dwLowDateTime + 5)/10; |
| 1778 | | - } |
| 1779 | | -#else |
| 1780 | | - struct rusage s; |
| 1781 | | - getrusage(RUSAGE_SELF, &s); |
| 1782 | | - if( piUser ){ |
| 1783 | | - *piUser = ((sqlite3_uint64)s.ru_utime.tv_sec)*1000000 + s.ru_utime.tv_usec; |
| 1784 | | - } |
| 1785 | | - if( piKernel ){ |
| 1786 | | - *piKernel = |
| 1787 | | - ((sqlite3_uint64)s.ru_stime.tv_sec)*1000000 + s.ru_stime.tv_usec; |
| 1788 | | - } |
| 1789 | | -#endif |
| 1790 | | -} |
| 1791 | 1754 | |
| 1792 | 1755 | /* |
| 1793 | 1756 | ** TH1 command: utime |
| 1794 | 1757 | ** |
| 1795 | 1758 | ** Return the number of microseconds of CPU time consumed by the current |
| | @@ -1802,11 +1765,11 @@ |
| 1802 | 1765 | const char **argv, |
| 1803 | 1766 | int *argl |
| 1804 | 1767 | ){ |
| 1805 | 1768 | sqlite3_uint64 x; |
| 1806 | 1769 | char zUTime[50]; |
| 1807 | | - getCpuTimes(&x, 0); |
| 1770 | + fossil_cpu_times(&x, 0); |
| 1808 | 1771 | sqlite3_snprintf(sizeof(zUTime), zUTime, "%llu", x); |
| 1809 | 1772 | Th_SetResult(interp, zUTime, -1); |
| 1810 | 1773 | return TH_OK; |
| 1811 | 1774 | } |
| 1812 | 1775 | |
| | @@ -1823,11 +1786,11 @@ |
| 1823 | 1786 | const char **argv, |
| 1824 | 1787 | int *argl |
| 1825 | 1788 | ){ |
| 1826 | 1789 | sqlite3_uint64 x; |
| 1827 | 1790 | char zUTime[50]; |
| 1828 | | - getCpuTimes(0, &x); |
| 1791 | + fossil_cpu_times(0, &x); |
| 1829 | 1792 | sqlite3_snprintf(sizeof(zUTime), zUTime, "%llu", x); |
| 1830 | 1793 | Th_SetResult(interp, zUTime, -1); |
| 1831 | 1794 | return TH_OK; |
| 1832 | 1795 | } |
| 1833 | 1796 | |
| 1834 | 1797 | |