summaryrefslogtreecommitdiff
path: root/Userland/allocate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/allocate.cpp')
-rw-r--r--Userland/allocate.cpp36
1 files changed, 19 insertions, 17 deletions
diff --git a/Userland/allocate.cpp b/Userland/allocate.cpp
index cb712b8b3d..c3bb3778a0 100644
--- a/Userland/allocate.cpp
+++ b/Userland/allocate.cpp
@@ -33,18 +33,20 @@
static void usage(void)
{
- printf("usage: allocate [number [unit (B/KB/MB)]]\n");
+ printf("usage: allocate [number [unit (B/KiB/MiB)]]\n");
exit(1);
}
-enum class Unit { Bytes,
- KiloBytes,
- MegaBytes };
+enum class Unit {
+ Bytes,
+ KiB,
+ MiB,
+};
int main(int argc, char** argv)
{
int count = 50;
- auto unit = Unit::MegaBytes;
+ auto unit = Unit::MiB;
if (argc >= 2) {
auto number = String(argv[1]).to_uint();
@@ -57,10 +59,10 @@ int main(int argc, char** argv)
if (argc >= 3) {
if (strcmp(argv[2], "B") == 0)
unit = Unit::Bytes;
- else if (strcmp(argv[2], "KB") == 0)
- unit = Unit::KiloBytes;
- else if (strcmp(argv[2], "MB") == 0)
- unit = Unit::MegaBytes;
+ else if (strcmp(argv[2], "KiB") == 0)
+ unit = Unit::KiB;
+ else if (strcmp(argv[2], "MiB") == 0)
+ unit = Unit::MiB;
else
usage();
}
@@ -68,11 +70,11 @@ int main(int argc, char** argv)
switch (unit) {
case Unit::Bytes:
break;
- case Unit::KiloBytes:
- count *= 1024;
+ case Unit::KiB:
+ count *= KiB;
break;
- case Unit::MegaBytes:
- count *= 1024 * 1024;
+ case Unit::MiB:
+ count *= MiB;
break;
}
@@ -87,7 +89,7 @@ int main(int argc, char** argv)
}
printf("done in %dms\n", timer.elapsed());
- auto pages = count / 4096;
+ auto pages = count / PAGE_SIZE;
auto step = pages / 10;
Core::ElapsedTimer timer2;
@@ -96,16 +98,16 @@ int main(int argc, char** argv)
timer.start();
timer2.start();
for (int i = 0; i < pages; ++i) {
- ptr[i * 4096] = 1;
+ ptr[i * PAGE_SIZE] = 1;
if (i != 0 && (i % step) == 0) {
auto ms = timer2.elapsed();
if (ms == 0)
ms = 1;
- auto bps = double(step * 4096) / (double(ms) / 1000);
+ auto bps = double(step * PAGE_SIZE) / (double(ms) / 1000);
- printf("step took %dms (%fMB/s)\n", ms, bps / 1024 / 1024);
+ printf("step took %dms (%fMiB/s)\n", ms, bps / MiB);
timer2.start();
}