Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Benchmark = require('benchmark');
- var escapeRegex = require('escape-string-regexp');
- var suite = new Benchmark.Suite;
- var text = "Contrary to popular belief, Lorem Ipsum is not simply random text. mouse It has roots in a mouse piece of classical Latin \
- literature from 45 BC, making it over 2000 mouse years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, \
- looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum mouse passage, and going through the cites of the word in \
- classical literature, fish discovered the mouse undoubtable source. Lorem mouse Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus \
- Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, mouse written in 45 BC. This book is a treatise on the theory of ethics, mouse \
- very popular during the Renaissance. The first line of Lorem Ipsum, Lorem ipsum dolor sit amet.., comes from a line in section 1.10.32. \
- The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those mouse interd. Sections 1.10.32 and 1.10.33 from de Finibus \
- Bonorum et mouse Malorum by Cicero are also mouse reproduced in their exact original form, accompanied by mouse English versions from the mouse \
- 1914 translation by H. Rackham. Contrary to popular belief, Lorem Ipsum is not simply random text. mouse It has roots in a mouse piece of classical \
- Latin literature from 45 BC, making it over 2000 mouse years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, \
- looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum mouse passage, and going through the cites of the word in classical \
- literature, fish discovered the mouse undoubtable source. Lorem mouse Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et \
- Malorum (The Extremes of Good and Evil) by Cicero, mouse written in 45 BC. This book is a treatise on the theory of ethics, mouse very popular \
- during the Renaissance. The first line of Lorem Ipsum, Lorem ipsum dolor sit amet.., comes from a line in section 1.10.32. The standard chunk of \
- Lorem Ipsum used since the 1500s is reproduced below for those mouse interd. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et mouse Malorum \
- by Cicero are also mouse reproduced in their exact original form, accompanied by mouse English versions from the mouse 1914 translation by H. Rackham. \
- Contrary to popular belief, Lorem Ipsum is not simply random text. mouse It has roots in a mouse piece of classical Latin literature from 45 \
- BC, making it over 2000 mouse years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the \
- more obscure Latin words, consectetur, from a Lorem Ipsum mouse passage, and going through the cites of the word in classical \
- literature, fish discovered the mouse undoubtable source. Lorem mouse Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus \
- Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, mouse written in 45 BC. This book is a treatise on the theory of \
- ethics, mouse very popular during the Renaissance. The first line of Lorem Ipsum, Lorem ipsum dolor sit amet.., comes from a line \
- in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those mouse interd. Sections 1.10.32 \
- and 1.10.33 from de Finibus Bonorum et mouse Malorum by Cicero are also mouse reproduced in their exact original form, accompanied by \
- mouse English versions from the mouse 1914 translation by H. Rackham. Contrary to popular belief, Lorem Ipsum is not simply random text. \
- mouse It has roots in a mouse piece of classical Latin literature from 45 BC, making it over 2000 mouse years old. Richard McClintock, a \
- Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum mouse \
- passage, and going through the cites of the word in classical literature, fish discovered the mouse undoubtable source. Lorem mouse Ipsum comes from \
- sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, mouse written in 45 BC. This book is a \
- treatise on the theory of ethics, mouse very popular during the Renaissance. The first line of Lorem Ipsum, Lorem ipsum dolor sit amet.., comes \
- from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those mouse interd. Sections 1.10.32 \
- and 1.10.33 from de Finibus Bonorum et mouse Malorum by Cicero are also mouse reproduced in their exact original form, accompanied by mouse English \
- versions from the mouse 1914 translation by H. Rackham. Contrary to popular belief, Lorem Ipsum is not simply random text. mouse It has roots in \
- a mouse piece of classical Latin literature from 45 BC, making it over 2000 mouse years old. Richard McClintock, a Latin professor at Hampden-Sydney \
- College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum mouse passage, and going through the cites of \
- the word in classical literature, fish discovered the mouse undoubtable source. Lorem mouse Ipsum comes from sections 1.10.32 and 1.10.33 of de \
- Finibus Bonorum et Malorum (The Extremes of Good and Evil) by Cicero, mouse written in 45 BC. This book is a treatise on the theory of ethics, mouse \
- very popular during the Renaissance. The first line of Lorem Ipsum, Lorem ipsum dolor sit amet.., comes from a line in section 1.10.32. The standard \
- chunk of Lorem Ipsum used since the 1500s is reproduced below for those mouse interd. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et mouse \
- Malorum by Cicero are also mouse reproduced in their exact original form, accompanied by mouse English versions from the mouse 1914 translation \
- by H. Rackham. Contrary to popular belief, Lorem Ipsum is not simply random text. mouse It has roots in a mouse piece of classical Latin \
- literature from 45 BC, making it over 2000 mouse years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked \
- up one of the more obscure Latin words, consectetur, from a Lorem Ipsum mouse passage, and going through the cites of the word in classical \
- literature, fish discovered the mouse undoubtable source. Lorem mouse Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et \
- Malorum (The Extremes of Good and Evil) by Cicero, mouse written in 45 BC. This book is a treatise on the theory of ethics, mouse very popular \
- during the Renaissance. The first line of Lorem Ipsum, Lorem ipsum dolor sit amet.., comes from a line in section 1.10.32. The standard chunk of \
- Lorem Ipsum used since the 1500s is reproduced below for those mouse interd. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et mouse Malorum \
- by Cicero are also mouse reproduced in their exact original form, accompanied by mouse English versions from the mouse 1914 translation by H. \
- Rackham. Contrary to popular belief, Lorem Ipsum is not simply random text. mouse It has roots in a mouse piece of classical Latin literature \
- from 45 BC, making it over 2000 mouse years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of \
- the more obscure Latin words, consectetur, from a Lorem Ipsum mouse passage, and going through the cites of the word in classical literature, mouse \
- discovered the mouse undoubtable source. Lorem mouse Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of \
- Good and Evil) by Cicero, mouse written in 45 BC. This book is a treatise on the theory of ethics, mouse very popular during the Renaissance. The \
- first line of Lorem Ipsum, Lorem ipsum dolor sit amet.., comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the \
- 1500s is reproduced below for those mouse interd. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et mouse Malorum by Cicero are also mouse \
- reproduced in their exact original form, accompanied by mouse English versions from the mouse 1914 translation by H. Rackham. Contrary to \
- popular belief, Lorem Ipsum is not simply random text. mouse It has roots in a mouse piece of classical Latin literature from 45 BC, making \
- it over 2000 mouse years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure \
- Latin words, consectetur, from a Lorem Ipsum mouse passage, and going through the cites of the word in classical literature, fish discovered \
- the mouse undoubtable source. Lorem mouse Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes of \
- Good and Evil) by Cicero, mouse written in 45 BC. This book is a treatise on the theory of ethics, mouse very popular during the Renaissance. \
- The first line of Lorem Ipsum, Lorem ipsum dolor sit amet.., comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used \
- since the 1500s is reproduced below for those mouse interd. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et mouse Malorum by Cicero \
- are also mouse reproduced in their exact original form, accompanied by mouse English versions from the mouse 1914 translation by H. Rackham. \
- Contrary to popular belief, Lorem Ipsum is not simply random text. mouse It has roots in a mouse piece of classical Latin literature from 45 \
- BC, making it over 2000 mouse years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the \
- more obscure Latin words, consectetur, from a Lorem Ipsum mouse passage, and going through the cites of the word in classical literature, fish \
- discovered the mouse undoubtable source. Lorem mouse Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum (The Extremes \
- of Good and Evil) by Cicero, mouse written in 45 BC. This book is a treatise on the theory of ethics, mouse very popular during the Renaissance. \
- The first line of Lorem Ipsum, Lorem ipsum dolor sit amet.., comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since \
- the 1500s is reproduced below for those mouse interd. Sections 1.10.32 and 1.10.33 from de Finibus Bonorum et mouse Malorum by Cicero are also \
- mouse reproduced in their exact original form, accompanied by mouse English versions from the mouse 1914 translation by H. Rackham. "
- var key = "mouse"
- var value = "fish"
- // add tests
- suite.add('RegExpReplace', function() {
- text = text.replace(new RegExp(key, 'g'), value);
- })
- .add('SplitJoin', function() {
- text = text.split(key).join(value);
- })
- .add('Loop', function() {
- while (text.indexOf(key) > -1) {
- text = text.replace(key, value);
- }
- })
- .add('RegExpReplaceEscape', function() {
- text = text.replace(new RegExp(escapeRegex(key), 'g'), value);
- })
- // add listeners
- .on('cycle', function(event) {
- console.log(String(event.target));
- })
- .on('complete', function() {
- console.log('Fastest is ' + this.filter('fastest').map('name'));
- })
- // run async
- .run({ 'async': true });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement