Classifies GPUs based on their 3D rendering benchmark score allowing the developer to provide sensible default settings for graphically intensive applications.
Installations
npm install detect-gpu
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
18.20.5
NPM Version
10.8.2
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (93.62%)
JavaScript (4.25%)
HTML (2.13%)
Developer
pmndrs
Download Statistics
Total Downloads
46,869,264
Last Day
41,113
Last Week
274,278
Last Month
1,743,794
Last Year
20,134,825
GitHub Statistics
1,072 Stars
734 Commits
58 Forks
18 Watching
13 Branches
44 Contributors
Bundle Size
6.94 kB
Minified
3.22 kB
Minified + Gzipped
Package Meta Information
Latest Version
5.0.63
Package Id
detect-gpu@5.0.63
Unpacked Size
954.32 kB
Size
123.37 kB
File Count
38
NPM Version
10.8.2
Node Version
18.20.5
Publised On
29 Dec 2024
Total Downloads
Cumulative downloads
Total Downloads
46,869,264
Last day
-12%
41,113
Compared to previous day
Last week
-29.1%
274,278
Compared to previous week
Last month
-10.4%
1,743,794
Compared to previous month
Last year
20.5%
20,134,825
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
27
Detect GPU
Classifies GPUs based on their 3D rendering benchmark score allowing the developer to provide sensible default settings for graphically intensive applications. Think of it like a user-agent detection for the GPU but more powerful.
Demo
Installation
By default we use the UNPKG CDN to host the benchmark data. If you would like to serve the benchmark data yourself download the required benchmarking data from benchmarks.tar.gz and serve it from a public directory.
Make sure you have Node.js installed.
1 $ npm install detect-gpu
Usage
1import { getGPUTier } from 'detect-gpu'; 2 3(async () => { 4 const gpuTier = await getGPUTier(); 5 6 // Example output: 7 // { 8 // "tier": 1, 9 // "isMobile": false, 10 // "type": "BENCHMARK", 11 // "fps": 21, 12 // "gpu": "intel iris graphics 6100" 13 // } 14})();
detect-gpu
uses rendering benchmark scores (framerate, normalized by resolution) in order to determine what tier should be assigned to the user's GPU. If no WebGLContext
can be created, the GPU is blocklisted or the GPU has reported to render on less than 15 fps
tier: 0
is assigned. One should provide a fallback to a non-WebGL experience.
Based on the reported fps
the GPU is then classified into either tier: 1 (>= 15 fps)
, tier: 2 (>= 30 fps)
or tier: 3 (>= 60 fps)
. The higher the tier the more graphically intensive workload you can offer to the user.
API
1getGPUTier({
2 /**
3 * URL of directory where benchmark data is hosted.
4 *
5 * @default https://unpkg.com/detect-gpu@{version}/dist/benchmarks
6 */
7 benchmarksURL?: string;
8 /**
9 * Optionally pass in a WebGL context to avoid creating a temporary one
10 * internally.
11 */
12 glContext?: WebGLRenderingContext | WebGL2RenderingContext;
13 /**
14 * Whether to fail if the system performance is low or if no hardware GPU is
15 * available.
16 *
17 * @default false
18 */
19 failIfMajorPerformanceCaveat?: boolean;
20 /**
21 * Framerate per tier for mobile devices.
22 *
23 * @defaultValue [0, 15, 30, 60]
24 */
25 mobileTiers?: number[];
26 /**
27 * Framerate per tier for desktop devices.
28 *
29 * @defaultValue [0, 15, 30, 60]
30 */
31 desktopTiers?: number[];
32 /**
33 * Optionally override specific parameters. Used mainly for testing.
34 */
35 override?: {
36 renderer?: string;
37 /**
38 * Override whether device is an iPad.
39 */
40 isIpad?: boolean;
41 /**
42 * Override whether device is a mobile device.
43 */
44 isMobile?: boolean;
45 /**
46 * Override device screen size.
47 */
48 screenSize?: { width: number; height: number };
49 /**
50 * Override how benchmark data is loaded
51 */
52 loadBenchmarks?: (file: string) => Promise<ModelEntry[]>;
53 };
54})
Support
Special care has been taken to make sure all browsers that support WebGL
are also supported by detect-gpu
including IE 11
.
Changelog
Licence
My work is released under the MIT license.
detect-gpu
uses both mobile and desktop benchmarking scores from https://gfxbench.com.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
13 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Warn: no topLevel permission defined: .github/workflows/update-benchmark.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/pmndrs/detect-gpu/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/pmndrs/detect-gpu/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/pmndrs/detect-gpu/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update-benchmark.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/pmndrs/detect-gpu/update-benchmark.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update-benchmark.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/pmndrs/detect-gpu/update-benchmark.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/update-benchmark.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/pmndrs/detect-gpu/update-benchmark.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/update-benchmark.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/pmndrs/detect-gpu/update-benchmark.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/update-benchmark.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/pmndrs/detect-gpu/update-benchmark.yml/master?enable=pin
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Reason
11 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
3.4
/10
Last Scanned on 2024-12-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More