Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
classcat, clsx, obj-str, vanilla, merge-class-names
(version: 0)
Comparing performance of:
classcat(arr) vs classcat(obj) vs clsx(arr) vs clsx(obj) vs objstr(obj) vs arr.filter(Boolean).join(" ") vs merge-class-names(arr) vs merge-class-names(obj)
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script type="module"> import classcat from "https://unpkg.com/classcat?module" window.classcat = classcat </script> <script type="module"> import objstr from "https://unpkg.com/obj-str?module" window.objstr = objstr </script> <script type="module"> import mergeClassNames from "https://unpkg.com/merge-class-names?module" window.mcn = mergeClassNames </script> <script src='https://unpkg.com/clsx@latest/dist/clsx.min.js'></script>
Script Preparation code:
var obj = { one: true, abcd: Math.random() <= 0.5, efghijkl: Math.random() <= 0.5, mnopqrstuvwxyz: Math.random() <= 0.5, efghijklmnopqrstuvwxyz: Math.random() <= 0.5, abcdefghijklmnopqrstuvwxyz: Math.random() <= 0.5, abcd: Math.random() <= 0.5, efghijkl: Math.random() <= 0.5, mnopqrstuvwxyz: Math.random() <= 0.5, efghijklmnopqrstuvwxyz: Math.random() <= 0.5, abcdefghijklmnopqrstuvwxyz: Math.random() <= 0.5, two: false, three: true } var arr = [ true && "one", Math.random() <= 0.5 && "abcd", Math.random() <= 0.5 && "efghijkl", Math.random() <= 0.5 && "mnopqrstuvwxyz", Math.random() <= 0.5 && "efghijklmnopqrstuvwxyz", Math.random() <= 0.5 && "abcdefghijklmnopqrstuvwxyz", Math.random() <= 0.5 && "abcd", Math.random() <= 0.5 && "efghijkl", Math.random() <= 0.5 && "mnopqrstuvwxyz", Math.random() <= 0.5 && "efghijklmnopqrstuvwxyz", Math.random() <= 0.5 && "abcdefghijklmnopqrstuvwxyz", false && "two", true && "three", ]
Tests:
classcat(arr)
window.classcat(arr)
classcat(obj)
window.classcat(obj)
clsx(arr)
clsx(arr)
clsx(obj)
clsx(obj)
objstr(obj)
window.objstr(obj)
arr.filter(Boolean).join(" ")
arr.filter(Boolean).join(" ")
merge-class-names(arr)
window.mcn(arr)
merge-class-names(obj)
window.mcn(obj)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (8)
Previous results
Fork
Test case name
Result
classcat(arr)
classcat(obj)
clsx(arr)
clsx(obj)
objstr(obj)
arr.filter(Boolean).join(" ")
merge-class-names(arr)
merge-class-names(obj)
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 break down the test cases and explain what's being tested, along with their pros and cons. **Classcat** * Test: `window.classcat(arr)` * Description: Classcat is a library that helps you create classes for objects in JavaScript. The benchmark tests how fast it can concatenate class names. * Pros: + Easy to use and understand + Provides a concise way to define classes for objects * Cons: + Can be slower than other alternatives due to the overhead of creating classes * Other considerations: Classcat is useful when you need to create classes dynamically or when working with complex object structures. **Clsx** * Test: `clsx(arr)` * Description: Clsx is a library that helps you compose functions for objects in JavaScript. The benchmark tests how fast it can execute the composed function. * Pros: + Fast and efficient + Easy to use and understand * Cons: + Requires manual function composition, which can be error-prone * Other considerations: Clsx is useful when you need to perform complex operations on objects or when working with large datasets. **Objstr** * Test: `objstr(obj)` * Description: Objstr is a library that helps you create object strings in JavaScript. The benchmark tests how fast it can concatenate property names. * Pros: + Fast and efficient + Easy to use and understand * Cons: + Limited functionality compared to other alternatives * Other considerations: Objstr is useful when you need to create object strings for debugging or logging purposes. **Arr.filter(Boolean).join(" ")** * Test: `arr.filter(Boolean).join(" ")" * Description: This benchmark tests the performance of filtering an array and then joining its elements with a string. * Pros: + Simple and easy to understand + Provides a good baseline for comparison * Cons: + Limited functionality compared to other alternatives * Other considerations: This benchmark is useful when you need to test the performance of array operations. In general, the benchmarks suggest that Clsx is the fastest followed by Objstr. Classcat is slower due to its class creation overhead. The `Arr.filter(Boolean).join(" ")` benchmark is relatively slow compared to the others.
Related benchmarks:
classcat, clsx, obj-str, vanilla
mergeByKey ES6 map + find vs Lodash vs ES6 Map
mergeByKey ES6 vs Lodash vs reduce
classnames , clsx, classcat
Comments
Confirm delete:
Do you really want to delete benchmark?