-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
invalid benchmark (and memory leak) #10
Comments
yep, here are some result of just comparing the raw power of using native vs repeat-string (\w cache turned off) async function code1() {
const mod = await import('https://jspm.dev/repeat-string')
const repeat = mod.default
const str1 = `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.`
const str2 = `It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).`
let i = 100_000
console.time('repeat-string')
while(i--) {
repeat(str1, 10)
repeat(str2, 10) // to clear cache
}
console.timeEnd('repeat-string')
}
async function code2() {
const str1 = `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.`
const str2 = `It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).`
let i = 100_000
console.time('native')
while(i--) {
str1.repeat(10)
str2.repeat(10)
}
console.timeEnd('native')
}
const blob1 = new Blob([code1.toString() + ';code1()'], { type: 'text/javascript' })
const blob2 = new Blob([code2.toString() + ';code2()'], { type: 'text/javascript' })
new Worker(URL.createObjectURL(blob2), { type: 'module'})
new Worker(URL.createObjectURL(blob1), { type: 'module'}) Chrome: 104 Safari: 15.6 Honestly you don't need any repeat library just use built in |
This library has a built-in cache, so any comparison to other libraries or native functions is useless and the documentation is misleading for developers.
Please correct the documentation and include information about the cache, which can be dangerous in some situations.
The text was updated successfully, but these errors were encountered: