String + operator vs Array.join

Benchmark created on


Description

Testing building a string via two methods: string + operator and Array.join. The parts of the string are: - A URL fragment (15 chars) - A question mark (1 char) - A small string (8 chars) - An equals sign (1 char) - Another small string (14 chars) - Another small string (14 chars) - A tiny string (3 chars) - A query string (55 chars)

Preparation HTML

<script>
  var url = '/user/login.php', jsonp = 'callback', id = 'hornet-jsonp-1', data = 'user[email]=my.email%40gmail.com&user[password]=letmein';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Array.join
[url, '?', jsonp, '=', 'Hornet.jsonp["', id, '"]&', data].join('');
ready
String + operator
url + '?' + jsonp + '=' + 'Hornet.jsonp["' + id + '"]&' + data;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.