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

Unified Diff: test/cctest/test-list-efficiency.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/cctest.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-list-efficiency.cc
diff --git a/test/cctest/test-platform.cc b/test/cctest/test-list-efficiency.cc
similarity index 61%
copy from test/cctest/test-platform.cc
copy to test/cctest/test-list-efficiency.cc
index 6c20b853c5e7408b1877ee74617c01c3fc32ed5f..6127d85dd5d9d7f5e57ee58a04977571f24c3f05 100644
--- a/test/cctest/test-platform.cc
+++ b/test/cctest/test-list-efficiency.cc
@@ -25,13 +25,48 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <stdlib.h>
+#include <sys/time.h>
+
+#include <algorithm>
+#include <vector>
#include "cctest.h"
-#include "platform.h"
+#include "list.h"
+
+using namespace v8::internal;
+
+TEST(TestListAndStdVector) {
+ CcTest::InitializeVM();
+
+ {
+ struct timeval tv_start;
+ gettimeofday(&tv_start, NULL);
+ std::vector<int> foo;
+ for (int i = 0; i < 10000; ++i)
+ foo.push_back(i % 1000);
+ std::sort(foo.begin(), foo.end());
+
+ struct timeval tv_stop;
+ gettimeofday(&tv_stop, NULL);
+ fprintf(stderr,
+ "std: %ld microseconds\n",
+ 1000000 * (tv_stop.tv_sec - tv_start.tv_sec) + tv_stop.tv_usec -
+ tv_start.tv_usec);
+ }
-using namespace ::v8::internal;
+ {
+ struct timeval tv_start;
+ gettimeofday(&tv_start, NULL);
+ List<int> foo;
+ for (int i = 0; i < 10000; ++i)
+ foo.Add(i % 1000);
+ foo.SortBetter();
-TEST(NumberOfCores) {
- CHECK_GT(OS::NumberOfCores(), 0);
+ struct timeval tv_stop;
+ gettimeofday(&tv_stop, NULL);
+ fprintf(stderr,
+ "list: %ld microseconds\n",
+ 1000000 * (tv_stop.tv_sec - tv_start.tv_sec) + tv_stop.tv_usec -
+ tv_start.tv_usec);
+ }
}
« no previous file with comments | « test/cctest/cctest.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698