Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
parenthesis or not
(version: 0)
Comparing performance of:
parenthesis vs without vs 3 vs 4
Created:
8 years ago
by:
Guest
Jump to the latest result
Tests:
parenthesis
var j = "MSKU765112"; var s = 0; var c1 = j.charCodeAt(0)-55; var c2 = j.charCodeAt(1)-55; var c3 = j.charCodeAt(2)-55; var c4 = j.charCodeAt(3)-55; s+=(Math.floor(c1/10.2)+c1)*1; s+=(Math.floor(c2/10.2)+c2)*2; s+=(Math.floor(c3/10.2)+c3)*4; s+=(Math.floor(c4/10.2)+c4)*8; s+=j.charCodeAt(4)*16-768; s+=j.charCodeAt(5)*32-1536; s+=j.charCodeAt(6)*64-3072; s+=j.charCodeAt(7)*128-6144; s+=j.charCodeAt(8)*256-12288; s+=j.charCodeAt(9)*512-24576; var d = s % 11 % 10; return d;
without
var j = "MSKU765112"; var s = 0; var c = j.charCodeAt(0)-55; s+=(Math.floor(c/10.2)+c)*1; var c = j.charCodeAt(1)-55; s+=(Math.floor(c/10.2)+c)*2; var c = j.charCodeAt(2)-55; s+=(Math.floor(c/10.2)+c)*4; var c = j.charCodeAt(3)-55; s+=(Math.floor(c/10.2)+c)*8; s+=j.charCodeAt(4)*16-768; s+=j.charCodeAt(5)*32-1536; s+=j.charCodeAt(6)*64-3072; s+=j.charCodeAt(7)*128-6144; s+=j.charCodeAt(8)*256-12288; s+=j.charCodeAt(9)*512-24576; var d = s % 11 % 10; return d;
3
var j = "MSKU765112"; var s = 0; var c = j.charCodeAt(0)-55; s+=(Math.floor(c/10.2)+c)*1; var c = j.charCodeAt(1)-55; s+=(Math.floor(c/10.2)+c)*2; var c = j.charCodeAt(2)-55; s+=(Math.floor(c/10.2)+c)*4; var c = j.charCodeAt(3)-55; s+=(Math.floor(c/10.2)+c)*8; s+=(j.charCodeAt(4)-48)*16; s+=(j.charCodeAt(5)-48)*32; s+=(j.charCodeAt(6)-48)*64; s+=(j.charCodeAt(7)-48)*128; s+=(j.charCodeAt(8)-48)*256; s+=(j.charCodeAt(9)-48)*512; var d = s % 11 % 10; return d;
4
var j = "MSKU765112"; var d = (((Math.floor((j.charCodeAt(0)-55)/10.2)+(j.charCodeAt(0)-55))*1)+((Math.floor((j.charCodeAt(1)-55)/10.2)+(j.charCodeAt(1)-55))*2)+((Math.floor((j.charCodeAt(2)-55)/10.2)+(j.charCodeAt(2)-55))*4)+((Math.floor((j.charCodeAt(3)-55)/10.2)+(j.charCodeAt(3)-55))*8)+(j.charCodeAt(4)*16-768)+(j.charCodeAt(5)*32-1536)+(j.charCodeAt(6)*64-3072)+(j.charCodeAt(7)*128-6144)+(j.charCodeAt(8)*256-12288)+(j.charCodeAt(9)*512-24576)) % 11 % 10; return d;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
parenthesis
without
3
4
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!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll explain the benchmark in detail. **Benchmark Overview** The benchmark tests the performance of a JavaScript interpreter by calculating a specific mathematical expression involving Unicode character codes. **Script Preparation Code** The script preparation code is empty, which means that the JavaScript interpreter needs to parse and execute the benchmark script from scratch. This approach provides an accurate measurement of the interpreter's performance but may be slower due to the overhead of parsing and compiling the script. **Benchmark Definition** The benchmark definition consists of a single expression: ```javascript var d = (((Math.floor((j.charCodeAt(0)-55)/10.2)+(j.charCodeAt(0)-55))*1)+((Math.floor((j.charCodeAt(1)-55)/10.2)+(j.charCodeAt(1)-55))*2)+((Math.floor((j.charCodeAt(2)-55)/10.2)+(j.charCodeAt(2)-55))*4)+((Math.floor((j.charCodeAt(3)-55)/10.2)+(j.charCodeAt(3)-55))*8)+(j.charCodeAt(4)*16-768)+(j.charCodeAt(5)*32-1536)+(j.charCodeAt(6)*64-3072)+(j.charCodeAt(7)*128-6144)+(j.charCodeAt(8)*256-12288)+(j.charCodeAt(9)*512-24576)) % 11 % 10; ``` This expression calculates the result of a modulo operation on the sum of products of character codes and their corresponding coefficients, modulo 11. **Test Cases** There are four test cases: 1. **"parenthesis"`**: This test case uses parentheses to group parts of the expression. 2. **"without"`**: This test case removes the parentheses from the expression. 3. **"3"`**: This test case uses a hardcoded value (3) instead of calculating it from character codes. 4. **"4"`**: This test case uses another hardcoded value (4) instead of calculating it from character codes. **Library Usage** The benchmark script does not explicitly use any libraries, but it relies on the built-in `Math` object for mathematical operations like `floor`, `charCodeAt`, and modulo calculations. **Special JS Features or Syntax** None of the benchmark scripts uses any special JavaScript features or syntax that is specific to a particular browser or interpreter. **Options Compared** The benchmark compares the performance of different approaches: 1. Using parentheses to group parts of the expression (Test Case "parenthesis"). 2. Removing parentheses from the expression (Test Case "without"). 3. Hardcoding values instead of calculating them from character codes (Test Cases "3" and "4"). **Device Platform, Operating System, and Browser** The benchmark results are reported for Firefox 54 on Windows 7 with other device platforms. In summary, this benchmark tests the performance of a JavaScript interpreter by evaluating a mathematical expression involving Unicode character codes. The test cases compare different approaches to grouping parts of the expression, using hardcoded values instead of calculations from character codes, and removing parentheses.
Related benchmarks:
IIFE vs Normal Fixed
IIFE vs Normal Fixed 2
jQuery parents() vs closest()
parentElement vs parentNode
parentElement vs parentNode (multiple)
Comments
Confirm delete:
Do you really want to delete benchmark?