Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Three.js vector copy proposal benchmark
(version: 2)
Comparing performance of:
Current copy vs Proposed copy
Created:
9 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/84/three.js" integrity="sha256-FlZMxx4ovIzb9UVKM4+xrQqIDgW2o1aEDVRXANdMpZU=" crossorigin="anonymous"></script>
Script Preparation code:
vec2 = new THREE.Vector2() vec3 = new THREE.Vector3() vec3.proposedCopy = function(v) { if ("x" in v) this.x = v.x; if ("y" in v) this.y = v.y; if ("z" in v) this.z = v.z; return this; }
Tests:
Current copy
vec3.copy(vec2)
Proposed copy
vec3.proposedCopy(vec2)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Current copy
Proposed copy
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 OPR/95.0.0.0
Browser/OS:
Opera 95 on Windows 7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Current copy
188562992.0 Ops/sec
Proposed copy
172307120.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided JSON data and explain what's being tested. **Benchmark Definition** The benchmark is defined by two test cases: "Current copy" and "Proposed copy". The benchmark is related to three.js, a JavaScript library for creating and displaying 3D graphics in the browser. Specifically, it tests the performance of copying vectors between `THREE.Vector2` (a 2D vector) and `THREE.Vector3` (a 3D vector). **Script Preparation Code** The script preparation code defines two variables: `vec2` and `vec3`, both instances of `THREE.Vector2` and `THREE.Vector3`, respectively. It also defines a function `vec3.proposedCopy` that takes a `THREE.Vector2` object as input and attempts to copy its properties (`x`, `y`, and `z`) to the corresponding fields in the `THREE.Vector3` object. **Html Preparation Code** The HTML preparation code includes a reference to the latest version of three.js, which is required for the benchmark to work. **Individual Test Cases** There are two test cases: 1. **Current copy**: This test case calls the built-in `copy()` method on the `vec3` object, passing the `vec2` object as an argument. 2. **Proposed copy**: This test case calls the custom `proposedCopy()` function defined in the script preparation code, passing the `vec2` object as an argument. **Pros and Cons of Different Approaches** The built-in `copy()` method is likely to be faster because it's a optimized implementation provided by three.js. However, this approach may not be suitable for all use cases, such as when you need more control over the copying process. The custom `proposedCopy()` function, on the other hand, provides more flexibility but may introduce overhead due to the additional function call and branching. **Other Considerations** * The benchmark measures the number of executions per second, which is a common metric for performance testing. * The test uses a real-world browser (Chrome 97) to simulate user interactions. * The benchmark runs on desktop platforms only, which may limit its relevance to mobile or other environments. **Alternatives** If you were to modify this benchmark or create new ones, you might consider: 1. Using different three.js versions or configurations to see how performance changes over time. 2. Adding more test cases for different vector sizes (e.g., `THREE.Vector4`). 3. Incorporating other libraries or frameworks that interact with three.js, such as physics engines or animation systems. 4. Measuring additional metrics, like memory usage or CPU utilization, to get a more comprehensive understanding of the system's performance. Keep in mind that these alternatives would require significant changes to the benchmark definition and script preparation code.
Related benchmarks:
Object Deep Copy Test3
Vec2 clone vs copyFrom
lodash _.cloneDeep() vs deppClone()
Lodash omit vs es omit vs compiled omit vs rest and delete omit vs babel - a lot of different objects
Array shallow copy - slice(0) vs conditional for() loop
Comments
Confirm delete:
Do you really want to delete benchmark?