Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: src/utils.h

Issue 13933026: Add a performance test showing that List is not as efficient as std::vector. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Better sort Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/list-inl.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_UTILS_H_ 28 #ifndef V8_UTILS_H_
29 #define V8_UTILS_H_ 29 #define V8_UTILS_H_
30 30
31 #include <stdlib.h> 31 #include <stdlib.h>
32 #include <string.h> 32 #include <string.h>
33 #include <algorithm>
33 #include <climits> 34 #include <climits>
34 35
35 #include "allocation.h" 36 #include "allocation.h"
36 #include "checks.h" 37 #include "checks.h"
37 #include "globals.h" 38 #include "globals.h"
38 39
39 namespace v8 { 40 namespace v8 {
40 namespace internal { 41 namespace internal {
41 42
42 // ---------------------------------------------------------------------------- 43 // ----------------------------------------------------------------------------
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 411 }
411 412
412 void Sort(int (*cmp)(const T*, const T*)) { 413 void Sort(int (*cmp)(const T*, const T*)) {
413 typedef int (*RawComparer)(const void*, const void*); 414 typedef int (*RawComparer)(const void*, const void*);
414 qsort(start(), 415 qsort(start(),
415 length(), 416 length(),
416 sizeof(T), 417 sizeof(T),
417 reinterpret_cast<RawComparer>(cmp)); 418 reinterpret_cast<RawComparer>(cmp));
418 } 419 }
419 420
421 void SortBetter() {
422 std::sort(start(), start() + length());
423 }
424
420 void Sort() { 425 void Sort() {
421 Sort(PointerValueCompare<T>); 426 Sort(PointerValueCompare<T>);
422 } 427 }
423 428
424 void Truncate(int length) { 429 void Truncate(int length) {
425 ASSERT(length <= length_); 430 ASSERT(length <= length_);
426 length_ = length; 431 length_ = length;
427 } 432 }
428 433
429 // Releases the array underlying this vector. Once disposed the 434 // Releases the array underlying this vector. Once disposed the
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 1088
1084 // Every compiled stub starts with this id. 1089 // Every compiled stub starts with this id.
1085 static const int kStubEntryId = 5; 1090 static const int kStubEntryId = 5;
1086 1091
1087 int id_; 1092 int id_;
1088 }; 1093 };
1089 1094
1090 } } // namespace v8::internal 1095 } } // namespace v8::internal
1091 1096
1092 #endif // V8_UTILS_H_ 1097 #endif // V8_UTILS_H_
OLDNEW
« no previous file with comments | « src/list-inl.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698