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

Unified Diff: runtime/vm/bit_set_test.cc

Issue 538213003: Speed up freelist by using intrinsics to find last set bit. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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 | « runtime/vm/bit_set.h ('k') | runtime/vm/freelist.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/bit_set_test.cc
===================================================================
--- runtime/vm/bit_set_test.cc (revision 0)
+++ runtime/vm/bit_set_test.cc (revision 0)
@@ -0,0 +1,51 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include "platform/assert.h"
+#include "vm/bit_set.h"
+#include "vm/unit_test.h"
+
+namespace dart {
+
+template<intptr_t Size>
+void TestBitSet() {
+ BitSet<Size> set;
+ EXPECT_EQ(-1, set.Last());
+ for (int i = 0; i < Size; ++i) {
+ EXPECT_EQ(false, set.Test(i));
+ set.Set(i, true);
+ EXPECT_EQ(true, set.Test(i));
+ EXPECT_EQ(i, set.Last());
+ for (int j = 0; j < Size; ++j) {
+ intptr_t next = set.Next(j);
+ if (j <= i) {
+ EXPECT_EQ(i, next);
+ } else {
+ EXPECT_EQ(-1, next);
+ }
+ }
+ set.Set(i, false);
+ EXPECT_EQ(false, set.Test(i));
+ }
+ set.Reset();
+ for (int i = 0; i < Size - 1; ++i) {
+ set.Set(i, true);
+ for (int j = i + 1; j < Size; ++j) {
+ set.Set(j, true);
+ EXPECT_EQ(j, set.Last());
+ EXPECT_EQ(i, set.ClearLastAndFindPrevious(j));
+ EXPECT_EQ(false, set.Test(j));
+ }
+ }
+}
+
+
+TEST_CASE(BitSetBasic) {
+ TestBitSet<8>();
+ TestBitSet<42>();
+ TestBitSet<128>();
+ TestBitSet<200>();
+}
+
+} // namespace dart
« no previous file with comments | « runtime/vm/bit_set.h ('k') | runtime/vm/freelist.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698