time-to-botec

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

README.md (2883B)


      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 # alloc
     22 
     23 > Allocate a [buffer][@stdlib/buffer/ctor] having a specified number of bytes.
     24 
     25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
     26 
     27 <section class="intro">
     28 
     29 </section>
     30 
     31 <!-- /.intro -->
     32 
     33 <!-- Package usage documentation. -->
     34 
     35 <section class="usage">
     36 
     37 ## Usage
     38 
     39 ```javascript
     40 var allocUnsafe = require( '@stdlib/buffer/alloc-unsafe' );
     41 ```
     42 
     43 #### allocUnsafe( size )
     44 
     45 **Unsafely** allocates a [buffer][@stdlib/buffer/ctor] having a specified number of bytes.
     46 
     47 ```javascript
     48 var buf = allocUnsafe( 10 );
     49 // returns <Buffer>
     50 ```
     51 
     52 </section>
     53 
     54 <!-- /.usage -->
     55 
     56 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     57 
     58 <section class="notes">
     59 
     60 ## Notes
     61 
     62 -   The underlying memory of returned [`Buffer`][@stdlib/buffer/ctor] instances is **not** initialized. Memory contents are unknown and may contain **sensitive** data.
     63 -   When the `size` is less than half the pool size (specified on the [`Buffer`][@stdlib/buffer/ctor] constructor in modern Node.js environments), memory is allocated from the [`Buffer`][@stdlib/buffer/ctor] pool for faster allocation of new [`Buffer`][@stdlib/buffer/ctor] instances.
     64 
     65 </section>
     66 
     67 <!-- /.notes -->
     68 
     69 <!-- Package usage examples. -->
     70 
     71 <section class="examples">
     72 
     73 ## Examples
     74 
     75 <!-- eslint no-undef: "error" -->
     76 
     77 ```javascript
     78 var allocUnsafe = require( '@stdlib/buffer/alloc-unsafe' );
     79 
     80 var buf;
     81 var i;
     82 
     83 // Repeatedly unsafely allocate memory and inspect the buffer contents...
     84 for ( i = 0; i < 100; i++ ) {
     85     buf = allocUnsafe( 100 );
     86     console.log( buf.toString() );
     87 }
     88 ```
     89 
     90 </section>
     91 
     92 <!-- /.examples -->
     93 
     94 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     95 
     96 <section class="references">
     97 
     98 </section>
     99 
    100 <!-- /.references -->
    101 
    102 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    103 
    104 <section class="links">
    105 
    106 [@stdlib/buffer/ctor]: https://www.npmjs.com/package/@stdlib/buffer/tree/main/ctor
    107 
    108 </section>
    109 
    110 <!-- /.links -->