Last updated

API / geotoolkit3d / util / benchmark / GPUBenchmark / GPUBenchmark

Class: GPUBenchmark

benchmark.GPUBenchmark.GPUBenchmark

Utility class to benchmark GPU.
This GPUBenchmark class provides the following GPU benchmark information:

  1. GPU information:
    General information about current browser, including GPU name and WebGL information.
  2. Graphic Performance Score:
    A score indicates the raw power of the GPU. The higher the score is, the better the GPU is.
    Usually, an mid-low-end integrated graphics card like Intel UHD Graphics 630 can reach about 460 score, a mid-end dedicated graphics card like NVIDIA GeForce GTX 1050 Ti can reach about 2200 score, and a high-end dedicated graphics card like NVIDIA GeForce RTX 3080 can reach about 20400 score.
  3. Estimated GPU memory:
    To determine the available GPU shared memory (both VRAM and shared RAM memory), this utility allocate GPU memory until the WebGL context drops (in a controlled manner).
    This allow us to get an estimation of the available memory.
    Because of web browser limitations, it is currently not possible to measure the exact VRAM capacity, and not possible either to distinguish the GPU VRAM from shared memory. Please note that after estimating GPU memory, it is necessary for the user to reload the page or even close the tab and reload to allow further WebGL context creation. Currently only supported on Windows Chrome and Mac Chrome due to the limitation of devices and browsers.

Table of contents

Constructors
Methods

Contents

Constructors

new GPUBenchmark()

new GPUBenchmark()

Methods

getClassName

getClassName(): string

Returns

string


formatBytes

Static formatBytes(bytes): string

Helper function to format bytes

Parameters

Name Type Description
bytesnumbernumber of bytes

Returns

string

formatted result


getClassName

Static getClassName(): string

Returns

string


getGPUInfo

Static getGPUInfo(): Promise<GPUInfo>

Get GPU information

Returns

Promise<GPUInfo>

GPUBenchmark.GPUInfo


isMemoryEstimateSupported

Static isMemoryEstimateSupported(): boolean

Check if GPUBenchmark.startMemoryEstimate is supported by current device.

Returns

boolean

true if supported, otherwise false


isScoreSupported

Static isScoreSupported(): boolean

Check if GPUBenchmark.startScoreBenchmark is supported by current device.

Returns

boolean

true if supported, otherwise false


startMemoryEstimate

Static startMemoryEstimate(container?): Promise<Result>

Start GPU memory estimation
This method will try to allocate as many textures as possible until the WebGL loses context.
The result is the number of bytes allocated. This result can provide a general idea of the GPU memory but not an exact number. The GPU memory estimation includes the GPU memory usage from both dedicated GPU memory and shared GPU memory.
Please be aware that this method will cause a page crash due to the GPU being out of memory, it has a chance that the WebGL context can be restored but not guaranteed.
Use it very carefully.

Parameters

Name Type Description
Optional containerHTMLElementIf the container is not provided, it will do the offscreen rendering, otherwise it will render the benchmark scene on the given canvas.

Returns

Promise<Result>


startScoreBenchmark

Static startScoreBenchmark(container?): Promise<number>

Start benchmarking GPU
A score that indicates the raw power of GPU will be returned after the benchmarking test.

Parameters

Name Type Description
Optional containerHTMLElementIf the container is not provided, it will do the offscreen rendering, otherwise it will render the benchmark scene on the given canvas.

Returns

Promise<number>