GithubHelp home page GithubHelp logo

kryndex / core-estimator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oftn-oswg/core-estimator

0.0 2.0 0.0 133 KB

Cross-browser polyfill for navigator.hardwareConcurrency

Home Page: https://oswg.oftn.org/projects/core-estimator/demo/

License: Other

Makefile 20.26% JavaScript 74.34% C++ 5.40%

core-estimator's Introduction

Core Estimator

Core Estimator is a cross-browser polyfill for navigator.hardwareConcurrency.

The estimator works by performing a timing attack that runs different numbers of simultaneous web workers. It measures the time it takes to run a single worker and compares this to the time it takes to run an increasing number of workers. As soon as this measurement starts to increase excessively, it has found the maximum number of web workers which can be run simultaneously without degrading performance.

Core Estimator only provides an estimate of the number of cores on your machine. The value may fluctuate depending on the system load caused by other programs currently running.

API

void navigator.getHardwareConcurrency(function callback(int cores), optional function progress(int min, int max, int cores))
Estimates the number of cores and passes the estimate to the callback. If navigator.hardwareConcurrency is is already available (either native API or it was previously estimated), it immediately calls the callback. Use progress if you're interested in the progress of the estimation as it completes.
int navigator.hardwareConcurrency
Either the number of logical or physical CPU cores the user's device has. Which it is depends on if estimation is used. If the browser does not natively support navigator.hardwareConcurrency, this will only be available after running navigator.getHardwareConcurrency() once.

Using Core Estimator

To install, place core-estimator.js, workload.js, and the nacl_module folder in the same public directory.

Include <script src="/path/to/core-estimator.js"></script> in the pages you wish to use the Core Estimator API.

Supported browsers

  • Firefox
  • Firefox 48 (Native)
  • Chrome (Native)
  • Safari (Native)
  • Internet Explorer 10+
  • Opera (Native)
  • Edge (Native)

Forward compatibility

In the future, when browser vendors implement navigator.hardwareConcurrency natively, Core Estimator will automatically detect and use the native method instead of estimating the number of cores.

core-estimator's People

Contributors

eligrey avatar dsamarin avatar lemmabit avatar yorickvp avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.