diff options
author | Arne Juul <arnej@verizonmedia.com> | 2021-02-15 13:54:24 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2021-02-15 14:16:17 +0000 |
commit | c0b8734987176a93588909739af143c6b0a1a6ff (patch) | |
tree | 33340f0cfc5e9e4b8691abdaa378712f3bf8ded5 /staging_vespalib | |
parent | e385cf1498861b27da4312828613bdabab9b2161 (diff) |
use size literals in vespalib
Diffstat (limited to 'staging_vespalib')
4 files changed, 14 insertions, 10 deletions
diff --git a/staging_vespalib/src/tests/directio/directio.cpp b/staging_vespalib/src/tests/directio/directio.cpp index 04155f71f94..7877216b191 100644 --- a/staging_vespalib/src/tests/directio/directio.cpp +++ b/staging_vespalib/src/tests/directio/directio.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/stllike/string.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/data/databuffer.h> #include <vespa/fastos/file.h> @@ -21,12 +22,12 @@ TEST("that DirectIOException is thrown on unaligned buf.") { FastOS_File f("staging_vespalib_directio_test_app"); f.EnableDirectIO(); EXPECT_TRUE(f.OpenReadOnly()); - DataBuffer buf(10000, 4096); + DataBuffer buf(10000, 4_Ki); bool caught(false); try { - f.ReadBuf(buf.getFree()+1, 4096, 0); + f.ReadBuf(buf.getFree()+1, 4_Ki, 0); } catch (const DirectIOException & e) { - EXPECT_EQUAL(4096u, e.getLength()); + EXPECT_EQUAL(4_Ki, e.getLength()); EXPECT_EQUAL(0u, e.getOffset()); EXPECT_EQUAL(buf.getFree()+1, e.getBuffer()); EXPECT_EQUAL(string(f.GetFileName()), e.getFileName()); @@ -39,12 +40,12 @@ TEST("that DirectIOException is thrown on unaligned offset.") { FastOS_File f("staging_vespalib_directio_test_app"); f.EnableDirectIO(); EXPECT_TRUE(f.OpenReadOnly()); - DataBuffer buf(10000, 4096); + DataBuffer buf(10000, 4_Ki); bool caught(false); try { - f.ReadBuf(buf.getFree(), 4096, 1); + f.ReadBuf(buf.getFree(), 4_Ki, 1); } catch (const DirectIOException & e) { - EXPECT_EQUAL(4096u, e.getLength()); + EXPECT_EQUAL(4_Ki, e.getLength()); EXPECT_EQUAL(1u, e.getOffset()); EXPECT_EQUAL(buf.getFree(), e.getBuffer()); EXPECT_EQUAL(string(f.GetFileName()), e.getFileName()); diff --git a/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp b/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp index e4274664336..0d33a27edbf 100644 --- a/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp +++ b/staging_vespalib/src/tests/util/process_memory_stats/process_memory_stats_test.cpp @@ -2,6 +2,7 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/process_memory_stats.h> +#include <vespa/vespalib/util/size_literals.h> #include <iostream> #include <fstream> #include <sys/mman.h> @@ -41,7 +42,7 @@ TEST("grow anonymous memory") { ProcessMemoryStats stats1(ProcessMemoryStats::create(SIZE_EPSILON)); std::cout << toString(stats1) << std::endl; - size_t mapLen = 64 * 1024; + size_t mapLen = 64_Ki; void *mapAddr = mmap(nullptr, mapLen, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); EXPECT_NOT_EQUAL(reinterpret_cast<void *>(-1), mapAddr); @@ -59,7 +60,7 @@ TEST("grow anonymous memory") TEST("grow mapped memory") { std::ofstream of("mapfile"); - size_t mapLen = 64 * 1024; + size_t mapLen = 64_Ki; std::vector<char> buf(mapLen, 4); of.write(&buf[0], buf.size()); of.close(); diff --git a/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp b/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp index 3f5b3b79656..9cd2ff59b49 100644 --- a/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/scheduledexecutor.cpp @@ -3,6 +3,7 @@ #include <vespa/fnet/scheduler.h> #include <vespa/fnet/task.h> #include <vespa/fnet/transport.h> +#include <vespa/vespalib/util/size_literals.h> namespace vespalib { @@ -35,7 +36,7 @@ public: }; ScheduledExecutor::ScheduledExecutor() - : _threadPool(128 * 1024), + : _threadPool(128_Ki), _transport(new FNET_Transport()), _lock(), _taskList() diff --git a/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp b/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp index b0c67e14c5b..102fdeb1d4e 100644 --- a/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/sequencedtaskexecutor.cpp @@ -4,6 +4,7 @@ #include "adaptive_sequenced_executor.h" #include "singleexecutor.h" #include <vespa/vespalib/util/blockingthreadstackexecutor.h> +#include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/stllike/hashtable.h> #include <cassert> @@ -11,7 +12,7 @@ namespace vespalib { namespace { -constexpr uint32_t stackSize = 128 * 1024; +constexpr uint32_t stackSize = 128_Ki; constexpr uint8_t MAGIC = 255; bool |