clock 0.1.2.1 → 0.2.0.0
raw patch · 9 files changed
+130/−159 lines, 9 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- AUTHORS +0/−1
- CHANGES +0/−33
- COPYING +2/−1
- LICENSE +0/−31
- README +0/−80
- clean +0/−2
- clock.cabal +7/−9
- csec/clock.c +121/−1
- edit +0/−1
− AUTHORS
@@ -1,1 +0,0 @@-Cetin Sert <cetin@sertcom.de>
− CHANGES
@@ -1,33 +0,0 @@-CHANGES-- 0.1.2.1:- → bugfix: System.Posix.Clock.getTime- this would call clock_getres internally- results were always the same with getRes-- → bugfix: System.Posix.Clock.sec- System.Posix.Clock.nsec- now properly exported-- 0.1.2: → System.CPUTime.Clock:- renamed to System.Posix.Clock because it contained a- posix-only implementation.-- later System.Windows.Clock can be implemented using- QueryPerformanceCounter, GetTickCount64, etc. and a- common interface could be exposed in System.Clock-- → System.Posix.Clock:- clock_gettime renamed to getTime- clock_getres renamed to getRes-- → System.Posix.Clock.TimeSpec:- now uses a record syntax and is also an instance of- Foreign.Storable, Eq and Ord.-- → Source Documentation:- improved according to IEEE Std 1003.1-2008- http://www.opengroup.org/onlinepubs/9699919799/--- 0.1.1: → added rudimentary documentation
COPYING view
@@ -1,4 +1,5 @@-Copyright (c) 2009, Cetin Sert+Copyright (c) 2010, Eugene Kirpichov+Copyright (c) 2009-2010, Cetin Sert All rights reserved.
− LICENSE
@@ -1,31 +0,0 @@-Copyright (c) 2009, Cetin Sert--All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions are-met:-- * Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.-- * Redistributions in binary form must reproduce the above- copyright notice, this list of conditions and the following- disclaimer in the documentation and/or other materials provided- with the distribution.-- * The names of contributors may not be used to endorse or promote- products derived from this software without specific prior- written permission. --THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
− README
@@ -1,80 +0,0 @@-------------------DEDICATED TO-- An Le Thi Thanh---------------------DESCRIPTION-- see- http://sert.homedns.org/hs/clock/dist/doc/html/clock/--- 0.1.2 (current version)-- System- Posix- Clock--- 1.0.0 (future projection)-- System- Clock- Posix- Clock- Windows- Clock---------------------CONSIDERATIONS-- → Implement System.Windows.Clock using QueryPerformanceCounter,- GetTickCount64, etc. and export a common interface in another- module System.Clock-- → System.Posix.Clock:- getRes has type 'Clock → IO TimeSpec' discuss changing this to- 'Clock → TimeSpec' with other haskell developers or read the- IEEE Std 1003.1-2008 thoroughly and decide on what to do.-- → System.Posix.Clock:- move to a more flexible clock_id representation so that we can- get the process/thread cpu-time for not just the caller but any- process/thread for which we can obtain a correspoinding clock_id-- → Namespaces:- use *.Clocks instead of *.Clock?---------------------KNOWN ISSUES-- → namespace(s) have not been confirmed final.-- → posix-only: windows implementation to be added later.-- → no tests.---------------------DISCLAIMER--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
− clean
@@ -1,2 +0,0 @@-cabal clean-find | grep -iE ~$ | xargs -n 1 rm &> /dev/null
clock.cabal view
@@ -1,11 +1,11 @@ Name: clock-Version: 0.1.2.1+Version: 0.2.0.0 License: BSD3 License-file: COPYING-Copyright: (c) 2009 Cetin Sert-Author: Cetin Sert <cetin@sertcom.de>+Copyright: (c) Cetin Sert 2009-2010, (c) Eugene Kirpichov 2010+Author: Cetin Sert <cetin@sertcom.de>, Eugene Kirpichov <ekirpichov@gmail.com> Maintainer: Cetin Sert <cetin@sertcom.de>-Homepage: http://sert.homedns.org/hs/clock+Homepage: http://corsis.sourceforge.net/index.php/Haskell/Clock Category: System Synopsis: High-resolution clock and timer functions: realtime, monotonic, cputime, etc.@@ -26,18 +26,16 @@ <http://www.opengroup.org/onlinepubs/9699919799/>, <http://www.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html#> .- WINDOWS reference: !! This early version is- posix-only and does not build on Windows. Support- will be added in the future. !!+ WINDOWS reference: ... . For more information, see:- <http://sert.homedns.org/hs/clock>+ <http://corsis.sourceforge.net/index.php/Haskell/Clock> Stability: Experimental Build-type: Simple Build-depends: base >= 2 && < 5 Exposed-Modules: System.Posix.Clock Extensions: ForeignFunctionInterface-C-sources: csec/clock.c+C-sources: csec/clock.c Include-dirs: csec Install-includes: clock.h ghc-options: -O2 -Wall -fglasgow-exts
csec/clock.c view
@@ -1,7 +1,125 @@ #include "clock.h"-#include <time.h> +#ifdef _WIN32 +// ***********************+// ******** WIN32 ********+// ***********************++#include <windows.h>++#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)+ #define U64(x) x##Ui64+#else+ #define U64(x) x##ULL+#endif++#define DELTA_EPOCH_IN_100NS U64(116444736000000000)++long ticks_to_nanos(LONGLONG subsecond_time, LONGLONG frequency)+{+ return (long)((1e9 * subsecond_time) / frequency);+}++ULONGLONG to_quad_100ns(FILETIME ft)+{+ ULARGE_INTEGER li;+ li.LowPart = ft.dwLowDateTime;+ li.HighPart = ft.dwHighDateTime;+ return li.QuadPart;+}++void to_timespec_from_100ns(ULONGLONG t_100ns, long *t)+{+ t[0] = (long)(t_100ns / 10000000UL);+ t[1] = 100*(long)(t_100ns % 10000000UL);+}++void clock_readtime_monotonic(long* t)+{+ LARGE_INTEGER time;+ LARGE_INTEGER frequency;+ QueryPerformanceCounter(&time);+ QueryPerformanceFrequency(&frequency);+ // seconds+ t[0] = time.QuadPart / frequency.QuadPart;+ // nanos = + t[1] = ticks_to_nanos(time.QuadPart % frequency.QuadPart, frequency.QuadPart);+}++void clock_readtime_realtime(long* t)+{+ FILETIME ft;+ ULONGLONG tmp;++ GetSystemTimeAsFileTime(&ft);+ + tmp = to_quad_100ns(ft);+ tmp -= DELTA_EPOCH_IN_100NS; ++ to_timespec_from_100ns(tmp, t);+}++void clock_readtime_processtime(long* t)+{+ FILETIME creation_time, exit_time, kernel_time, user_time;+ ULONGLONG time;++ GetProcessTimes(GetCurrentProcess(), &creation_time, &exit_time, &kernel_time, &user_time);+ // Both kernel and user, acc. to http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#tag_03_117++ time = to_quad_100ns(user_time) + to_quad_100ns(kernel_time);+ to_timespec_from_100ns(time, t);+}++void clock_readtime_threadtime(long* t)+{+ FILETIME creation_time, exit_time, kernel_time, user_time;+ ULONGLONG time;++ GetThreadTimes(GetCurrentThread(), &creation_time, &exit_time, &kernel_time, &user_time);+ // Both kernel and user, acc. to http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#tag_03_117++ time = to_quad_100ns(user_time) + to_quad_100ns(kernel_time);+ to_timespec_from_100ns(time, t);+}++void clock_readres_monotonic(long* t)+{+ LARGE_INTEGER frequency;+ QueryPerformanceFrequency(&frequency);++ ULONGLONG resolution = U64(1000000000)/frequency.QuadPart;+ t[0] = resolution / U64(1000000000);+ t[1] = resolution % U64(1000000000);+}++void clock_readres_realtime(long* t)+{+ t[0] = 0;+ t[1] = 100;+}++void clock_readres_processtime(long* t)+{+ t[0] = 0;+ t[1] = 100;+}++void clock_readres_threadtime(long* t)+{+ t[0] = 0;+ t[1] = 100;+}++#else // Not _WIN32++// ***********************+// ******** POSIX ********+// ***********************++#include <time.h>+ void time_(clockid_t clock, long* t) { @@ -70,3 +188,5 @@ { res_(CLOCK_THREAD_CPUTIME_ID , t); }++#endif
− edit
@@ -1,1 +0,0 @@-gedit AUTHORS README CHANGES clock.cabal csec/*.c csec/*.h System/CPUTime/*.hs &