From 1d25907f303e756138bcd5fce3721de9801f8f48 Mon Sep 17 00:00:00 2001 From: landerlyoung Date: Wed, 7 Feb 2024 13:01:10 +0800 Subject: [PATCH] fix typo ByteBuffer::Type::KFloat32 -> ByteBuffer::Type::kFloat32 --- backend/JavaScriptCore/JscLocalReference.cc | 2 +- backend/QuickJs/QjsEngine.cc | 4 ++-- backend/Template/TemplateLocalReference.cc | 2 +- backend/V8/V8LocalReference.cc | 2 +- backend/WebAssembly/WasmHelper.cc | 4 ++-- src/Value.h | 2 +- test/src/ByteBufferTest.cc | 2 +- test/src/ThreadPoolTest.cc | 16 +++++++++++++--- 8 files changed, 22 insertions(+), 12 deletions(-) diff --git a/backend/JavaScriptCore/JscLocalReference.cc b/backend/JavaScriptCore/JscLocalReference.cc index 67e6829d..57b742e4 100644 --- a/backend/JavaScriptCore/JscLocalReference.cc +++ b/backend/JavaScriptCore/JscLocalReference.cc @@ -501,7 +501,7 @@ ByteBuffer::Type mapType(JSTypedArrayType type) { case kJSTypedArrayTypeUint32Array: return ByteBuffer::Type::kUint32; case kJSTypedArrayTypeFloat32Array: - return ByteBuffer::Type::KFloat32; + return ByteBuffer::Type::kFloat32; case kJSTypedArrayTypeFloat64Array: return ByteBuffer::Type::kFloat64; case kJSTypedArrayTypeArrayBuffer: diff --git a/backend/QuickJs/QjsEngine.cc b/backend/QuickJs/QjsEngine.cc index aee25b48..eb7032b3 100644 --- a/backend/QuickJs/QjsEngine.cc +++ b/backend/QuickJs/QjsEngine.cc @@ -37,7 +37,7 @@ constexpr auto kGetByteBufferInfo = R"( const kUint32 = 0x604; const kInt64 = 0x708; const kUint64 = 0x808; - const KFloat32 = 0x904; + const kFloat32 = 0x904; const kFloat64 = 0xa08; let byteBuffer = val; @@ -64,7 +64,7 @@ constexpr auto kGetByteBufferInfo = R"( } else if (val instanceof Uint32Array) { type = kUint32; } else if (val instanceof Float32Array) { - type = KFloat32; + type = kFloat32; } else if (val instanceof Float64Array) { type = kFloat64; } else if (val instanceof BigInt64Array) { diff --git a/backend/Template/TemplateLocalReference.cc b/backend/Template/TemplateLocalReference.cc index d4f202d8..f86dadac 100644 --- a/backend/Template/TemplateLocalReference.cc +++ b/backend/Template/TemplateLocalReference.cc @@ -199,7 +199,7 @@ void Local::add(const script::Local& value) const { set(si void Local::clear() const {} -ByteBuffer::Type Local::getType() const { return ByteBuffer::Type::KFloat32; } +ByteBuffer::Type Local::getType() const { return ByteBuffer::Type::kFloat32; } bool Local::isShared() const { return true; } diff --git a/backend/V8/V8LocalReference.cc b/backend/V8/V8LocalReference.cc index 549a7663..dc3f3ffe 100644 --- a/backend/V8/V8LocalReference.cc +++ b/backend/V8/V8LocalReference.cc @@ -378,7 +378,7 @@ ByteBuffer::Type Local::getType() const { } else if (val_->IsBigUint64Array()) { return ByteBuffer::Type::kUint64; } else if (val_->IsFloat32Array()) { - return ByteBuffer::Type::KFloat32; + return ByteBuffer::Type::kFloat32; } else if (val_->IsFloat64Array()) { return ByteBuffer::Type::kFloat64; } diff --git a/backend/WebAssembly/WasmHelper.cc b/backend/WebAssembly/WasmHelper.cc index 8234627c..af6613d5 100644 --- a/backend/WebAssembly/WasmHelper.cc +++ b/backend/WebAssembly/WasmHelper.cc @@ -873,7 +873,7 @@ CHECKED_EM_JS(void, _ScriptX_ByteBuffer_fillTypeAndSize, const kUint32 = 0x604; const kInt64 = 0x708; const kUint64 = 0x808; - const KFloat32 = 0x904; + const kFloat32 = 0x904; const kFloat64 = 0xa08; let type = kUnspecified; @@ -892,7 +892,7 @@ CHECKED_EM_JS(void, _ScriptX_ByteBuffer_fillTypeAndSize, } else if (val instanceof Uint32Array) { type = kUint32; } else if (val instanceof Float32Array) { - type = KFloat32; + type = kFloat32; } else if (val instanceof Float64Array) { type = kFloat64; } else if (val instanceof BigInt64Array) { diff --git a/src/Value.h b/src/Value.h index 629f6567..28a83ec9 100644 --- a/src/Value.h +++ b/src/Value.h @@ -282,7 +282,7 @@ class ByteBuffer : public Value { kUint32 = internal::makeType(6, 4), kInt64 = internal::makeType(7, 8), kUint64 = internal::makeType(8, 8), - KFloat32 = internal::makeType(9, 4), + kFloat32 = internal::makeType(9, 4), kFloat64 = internal::makeType(10, 8) }; diff --git a/test/src/ByteBufferTest.cc b/test/src/ByteBufferTest.cc index a80d5a1e..0838aa27 100644 --- a/test/src/ByteBufferTest.cc +++ b/test/src/ByteBufferTest.cc @@ -136,7 +136,7 @@ TEST_F(ByteBufferTest, DataView) { {"BigInt64Array", ByteBuffer::Type::kInt64}, {"BigUint64Array", ByteBuffer::Type::kUint64}, #endif - {"Float32Array", ByteBuffer::Type::KFloat32}, + {"Float32Array", ByteBuffer::Type::kFloat32}, {"Float64Array", ByteBuffer::Type::kFloat64}, {"DataView", ByteBuffer::Type::kUnspecified}}) { std::ostringstream code; diff --git a/test/src/ThreadPoolTest.cc b/test/src/ThreadPoolTest.cc index 1fb8b40f..21606e6d 100644 --- a/test/src/ThreadPoolTest.cc +++ b/test/src/ThreadPoolTest.cc @@ -17,6 +17,7 @@ #include #include +#include #include #include "test.h" @@ -74,8 +75,6 @@ TEST(ThreadPool, MultiThreadRun) { EXPECT_EQ(max * kProducerCount, i->load()); } -static constexpr auto kEnableMultiThreadTest = true; - template void runThreadpoolBenchmark() { using std::chrono::duration; @@ -85,7 +84,8 @@ void runThreadpoolBenchmark() { using std::chrono::steady_clock; using std::chrono_literals::operator""ms; - constexpr auto kRunTimeMs = 1000ms; + constexpr auto kEnableMultiThreadTest = false; + constexpr auto kRunTimeMs = 200ms; // simple benchmark if (!kEnableMultiThreadTest) return; @@ -101,6 +101,16 @@ void runThreadpoolBenchmark() { tp.postMessage(stopMsg, kRunTimeMs); + auto handleMessage = [](Message& msg) { + auto* i = static_cast(msg.ptr0); + for (int j = 0; j < 100 * 1000; ++j) { + // do a bit havey work + auto x = sinf(i->load()); + static_cast(x); + } + (*i)++; + }; + std::array, kProducerThreads> p; for (auto& t : p) { t = std::make_unique([&]() {