time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (8157B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # Time
     22 
     23 [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url]
     24 
     25 > Standard library time utilities.
     26 
     27 <section class="installation">
     28 
     29 ## Installation
     30 
     31 ```bash
     32 npm install @stdlib/time
     33 ```
     34 
     35 </section>
     36 
     37 <section class="usage">
     38 
     39 ## Usage
     40 
     41 ```javascript
     42 var time = require( '@stdlib/time' );
     43 ```
     44 
     45 #### time
     46 
     47 Standard library time utilities.
     48 
     49 ```javascript
     50 var ns = time;
     51 // returns {...}
     52 ```
     53 
     54 ### Calendar Utilities
     55 
     56 <!-- <toc keywords="+calendar"> -->
     57 
     58 <div class="namespace-toc">
     59 
     60 -   <span class="signature">[`dayOfQuarter( [month[, day, year]] )`][@stdlib/time/day-of-quarter]</span><span class="delimiter">: </span><span class="description">determine the day of the quarter.</span>
     61 -   <span class="signature">[`dayOfYear( [month[, day, year]] )`][@stdlib/time/day-of-year]</span><span class="delimiter">: </span><span class="description">determine the day of the year.</span>
     62 -   <span class="signature">[`daysInMonth( [month[, year]] )`][@stdlib/time/days-in-month]</span><span class="delimiter">: </span><span class="description">determine the number of days in a month.</span>
     63 -   <span class="signature">[`daysInYear( [value] )`][@stdlib/time/days-in-year]</span><span class="delimiter">: </span><span class="description">determine the number of days in a year according to the Gregorian calendar.</span>
     64 -   <span class="signature">[`hoursInMonth( [month[, year]] )`][@stdlib/time/hours-in-month]</span><span class="delimiter">: </span><span class="description">determine the number of hours in a month.</span>
     65 -   <span class="signature">[`hoursInYear( [value] )`][@stdlib/time/hours-in-year]</span><span class="delimiter">: </span><span class="description">determine the number of hours in a year according to the Gregorian calendar.</span>
     66 -   <span class="signature">[`isoWeeksInYear( [value] )`][@stdlib/time/iso-weeks-in-year]</span><span class="delimiter">: </span><span class="description">determine the number of ISO weeks in a year according to the Gregorian calendar.</span>
     67 -   <span class="signature">[`minutesInMonth( [month[, year]] )`][@stdlib/time/minutes-in-month]</span><span class="delimiter">: </span><span class="description">determine the number of minutes in a month.</span>
     68 -   <span class="signature">[`minutesInYear( [value] )`][@stdlib/time/minutes-in-year]</span><span class="delimiter">: </span><span class="description">determine the number of minutes in a year according to the Gregorian calendar.</span>
     69 -   <span class="signature">[`quarterOfYear( [month] )`][@stdlib/time/quarter-of-year]</span><span class="delimiter">: </span><span class="description">determine the quarter of the year.</span>
     70 -   <span class="signature">[`secondsInMonth( [month[, year]] )`][@stdlib/time/seconds-in-month]</span><span class="delimiter">: </span><span class="description">determine the number of seconds in a month.</span>
     71 -   <span class="signature">[`secondsInYear( [value] )`][@stdlib/time/seconds-in-year]</span><span class="delimiter">: </span><span class="description">determine the number of seconds in a year according to the Gregorian calendar.</span>
     72 
     73 </div>
     74 
     75 <!-- </toc> -->
     76 
     77 ```javascript
     78 var num = time.daysInYear( 2000 );
     79 // returns 366
     80 
     81 num = time.hoursInMonth( 2, 2017 );
     82 // returns 672
     83 ```
     84 
     85 ### Timer Utilities
     86 
     87 <!-- <toc keywords="+timer"> -->
     88 
     89 <div class="namespace-toc">
     90 
     91 -   <span class="signature">[`tic()`][@stdlib/time/tic]</span><span class="delimiter">: </span><span class="description">return a high-resolution time.</span>
     92 -   <span class="signature">[`toc( time )`][@stdlib/time/toc]</span><span class="delimiter">: </span><span class="description">return a high-resolution time difference.</span>
     93 
     94 </div>
     95 
     96 <!-- </toc> -->
     97 
     98 ```javascript
     99 var time = require( '@stdlib/time' );
    100 
    101 var start = time.tic();
    102 
    103 setTimeout( onTimeout, 2000 );
    104 
    105 function onTimeout() {
    106     var elapsed = time.toc( start );
    107     console.log( 'Elapsed: %d seconds and %d nanoseconds', elapsed[0], elapsed[1] );
    108 }
    109 ```
    110 
    111 </section>
    112 
    113 <!-- /.usage -->
    114 
    115 <section class="examples">
    116 
    117 ## Examples
    118 
    119 <!-- TODO: better examples -->
    120 
    121 <!-- eslint no-undef: "error" -->
    122 
    123 ```javascript
    124 var objectKeys = require( '@stdlib/utils/keys' );
    125 var time = require( '@stdlib/time' );
    126 
    127 console.log( objectKeys( time ) );
    128 ```
    129 
    130 </section>
    131 
    132 <!-- /.examples -->
    133 
    134 
    135 <section class="main-repo" >
    136 
    137 * * *
    138 
    139 ## Notice
    140 
    141 This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
    142 
    143 For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
    144 
    145 #### Community
    146 
    147 [![Chat][chat-image]][chat-url]
    148 
    149 ---
    150 
    151 ## License
    152 
    153 See [LICENSE][stdlib-license].
    154 
    155 
    156 ## Copyright
    157 
    158 Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
    159 
    160 </section>
    161 
    162 <!-- /.stdlib -->
    163 
    164 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    165 
    166 <section class="links">
    167 
    168 [npm-image]: http://img.shields.io/npm/v/@stdlib/time.svg
    169 [npm-url]: https://npmjs.org/package/@stdlib/time
    170 
    171 [test-image]: https://github.com/stdlib-js/time/actions/workflows/test.yml/badge.svg
    172 [test-url]: https://github.com/stdlib-js/time/actions/workflows/test.yml
    173 
    174 [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/time/main.svg
    175 [coverage-url]: https://codecov.io/github/stdlib-js/time?branch=main
    176 
    177 [dependencies-image]: https://img.shields.io/david/stdlib-js/time.svg
    178 [dependencies-url]: https://david-dm.org/stdlib-js/time/main
    179 
    180 [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
    181 [chat-url]: https://gitter.im/stdlib-js/stdlib/
    182 
    183 [stdlib]: https://github.com/stdlib-js/stdlib
    184 
    185 [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
    186 
    187 [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/time/main/LICENSE
    188 
    189 <!-- <toc-links> -->
    190 
    191 [@stdlib/time/tic]: https://www.npmjs.com/package/@stdlib/time/tree/main/tic
    192 
    193 [@stdlib/time/toc]: https://www.npmjs.com/package/@stdlib/time/tree/main/toc
    194 
    195 [@stdlib/time/day-of-quarter]: https://www.npmjs.com/package/@stdlib/time/tree/main/day-of-quarter
    196 
    197 [@stdlib/time/day-of-year]: https://www.npmjs.com/package/@stdlib/time/tree/main/day-of-year
    198 
    199 [@stdlib/time/days-in-month]: https://www.npmjs.com/package/@stdlib/time/tree/main/days-in-month
    200 
    201 [@stdlib/time/days-in-year]: https://www.npmjs.com/package/@stdlib/time/tree/main/days-in-year
    202 
    203 [@stdlib/time/hours-in-month]: https://www.npmjs.com/package/@stdlib/time/tree/main/hours-in-month
    204 
    205 [@stdlib/time/hours-in-year]: https://www.npmjs.com/package/@stdlib/time/tree/main/hours-in-year
    206 
    207 [@stdlib/time/iso-weeks-in-year]: https://www.npmjs.com/package/@stdlib/time/tree/main/iso-weeks-in-year
    208 
    209 [@stdlib/time/minutes-in-month]: https://www.npmjs.com/package/@stdlib/time/tree/main/minutes-in-month
    210 
    211 [@stdlib/time/minutes-in-year]: https://www.npmjs.com/package/@stdlib/time/tree/main/minutes-in-year
    212 
    213 [@stdlib/time/quarter-of-year]: https://www.npmjs.com/package/@stdlib/time/tree/main/quarter-of-year
    214 
    215 [@stdlib/time/seconds-in-month]: https://www.npmjs.com/package/@stdlib/time/tree/main/seconds-in-month
    216 
    217 [@stdlib/time/seconds-in-year]: https://www.npmjs.com/package/@stdlib/time/tree/main/seconds-in-year
    218 
    219 <!-- </toc-links> -->
    220 
    221 </section>
    222 
    223 <!-- /.links -->