Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
/ deno_num_cpus Public archive

Get the number of CPUs available on the current system.

License

Notifications You must be signed in to change notification settings

justjavac/deno_num_cpus

Repository files navigation

deno_num_cpus

tag Build Status license

Get the number of CPUs available on the current system.

Sometimes the CPU will exaggerate the number of CPUs it contains, because it can use processor tricks to deliver increased performance when there are more threads. This crate provides methods to get both the logical and physical numbers of cores.

This information can be used as a guide to how many tasks can be run in parallel. There are many properties of the system architecture that will affect parallelism, for example memory access speeds (for all the caches and RAM) and the physical architecture of the processor, so the number of CPUs should be used as a rough guide only.

Usage

import numCpus from "https://deno.land/x/num_cpus/mod.ts";

numCpus();
// => 8

run example:

deno run -A --unstable https://deno.land/x/num_cpus/example.ts

Flags

  • --unstable
  • --allow-plugin

License

deno_num_cpus is released under the MIT License. See the bundled LICENSE file for details.