binary search vs loop
JavaScript performance comparison
Info
Looks at the performance difference between brute force searching and binary search
Preparation code
<script>
for (var i = 0, searchArr = []; i < 2000; i++) {
searchArr[i] = i;
}
var count = 0,
curVal = 0;
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
brute force |
|
pending… |
binary |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Jason
- Revision 2: published by Mike
- Revision 12: published
- Revision 16: published
1 comment
Your binary search will only work on an ordered list correct?