hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

+freebsd.ha (566B)


      1 // License: MPL-2.0
      2 // (c) 2021 Drew DeVault <sir@cmpwn.com>
      3 
      4 let start: timespec = timespec { ... };
      5 
      6 fn time_start() void = {
      7 	clock_gettime(CLOCK_MONOTONIC, &start) as void;
      8 };
      9 
     10 // Returns elapsed time as (seconds, milliseconds)
     11 fn time_stop() (size, size) = {
     12 	let end: timespec = timespec { ... };
     13 	clock_gettime(CLOCK_MONOTONIC, &end) as void;
     14 	let sec_diff = end.tv_sec - start.tv_sec;
     15 	let nsec_diff = end.tv_nsec - start.tv_nsec;
     16 	if (nsec_diff < 0) {
     17 		nsec_diff += 1000000000;
     18 		sec_diff -= 1;
     19 	};
     20 	return (sec_diff: size, nsec_diff: size / 1000000z);
     21 };