Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
set buffer data
(version: 0)
Comparing performance of:
test array 1 vs test array 2
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
// 初始化 WebGL 上下文 const canvas = document.createElement('canvas'); const gl = canvas.getContext('webgl'); // 创建 WebGL buffer const buffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, buffer); // 函数:测量 bufferSubData 的运行时间 function measureBufferSubDataPerformance(array: Float32Array) { // 创建一个 GPU 上的空 buffer,并分配与 Float32Array 相同大小的空间 gl.bufferData(gl.ARRAY_BUFFER, array.length * 4, gl.DYNAMIC_DRAW); // 记录开始时间 const startTime = performance.now(); // 使用 bufferSubData 更新 buffer 数据 gl.bufferSubData(gl.ARRAY_BUFFER, 0, array); // 记录结束时间 const endTime = performance.now(); // 返回耗时 return endTime - startTime; } // 示例用法 const array1 = new Float32Array(1000); // 创建一个长度为1000的Float32Array const array2 = new Float32Array(10000); // 创建一个长度为10000的Float32Array const array3 = new Float32Array(100000); // 创建一个长度为100000的Float32Array // 填充数组(可以使用你已有的Float32Array对象) for (let i = 0; i < array1.length; i++) { array1[i] = Math.random(); } for (let i = 0; i < array2.length; i++) { array2[i] = Math.random(); } for (let i = 0; i < array3.length; i++) { array3[i] = Math.random(); }
Tests:
test array 1
// 测试不同大小的 Float32Array 在 bufferSubData 上的耗时 const time1 = measureBufferSubDataPerformance(array1); console.log(`Time for array1 (1000 elements): ${time1} ms`);
test array 2
// 测试不同大小的 Float32Array 在 bufferSubData 上的耗时 const time2 = measureBufferSubDataPerformance(array2); console.log(`Time for array2 (10000 elements): ${time2} ms`);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
test array 1
test array 2
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?