Skip to content

Commit

Permalink
fix typo ByteBuffer::Type::KFloat32 -> ByteBuffer::Type::kFloat32
Browse files Browse the repository at this point in the history
  • Loading branch information
LanderlYoung committed Feb 7, 2024
1 parent 191d404 commit 1d25907
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion backend/JavaScriptCore/JscLocalReference.cc
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions backend/QuickJs/QjsEngine.cc
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion backend/Template/TemplateLocalReference.cc
Expand Up @@ -199,7 +199,7 @@ void Local<Array>::add(const script::Local<script::Value>& value) const { set(si

void Local<Array>::clear() const {}

ByteBuffer::Type Local<ByteBuffer>::getType() const { return ByteBuffer::Type::KFloat32; }
ByteBuffer::Type Local<ByteBuffer>::getType() const { return ByteBuffer::Type::kFloat32; }

bool Local<ByteBuffer>::isShared() const { return true; }

Expand Down
2 changes: 1 addition & 1 deletion backend/V8/V8LocalReference.cc
Expand Up @@ -378,7 +378,7 @@ ByteBuffer::Type Local<ByteBuffer>::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;
}
Expand Down
4 changes: 2 additions & 2 deletions backend/WebAssembly/WasmHelper.cc
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Value.h
Expand Up @@ -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)
};

Expand Down
2 changes: 1 addition & 1 deletion test/src/ByteBufferTest.cc
Expand Up @@ -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;
Expand Down
16 changes: 13 additions & 3 deletions test/src/ThreadPoolTest.cc
Expand Up @@ -17,6 +17,7 @@

#include <array>
#include <atomic>
#include <cmath>
#include <iomanip>
#include "test.h"

Expand Down Expand Up @@ -74,8 +75,6 @@ TEST(ThreadPool, MultiThreadRun) {
EXPECT_EQ(max * kProducerCount, i->load());
}

static constexpr auto kEnableMultiThreadTest = true;

template <size_t kProducerThreads, size_t kWorkerThreads>
void runThreadpoolBenchmark() {
using std::chrono::duration;
Expand All @@ -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;
Expand All @@ -101,6 +101,16 @@ void runThreadpoolBenchmark() {

tp.postMessage(stopMsg, kRunTimeMs);

auto handleMessage = [](Message& msg) {
auto* i = static_cast<std::atomic_int64_t*>(msg.ptr0);
for (int j = 0; j < 100 * 1000; ++j) {
// do a bit havey work
auto x = sinf(i->load());
static_cast<void>(x);
}
(*i)++;
};

std::array<std::unique_ptr<std::thread>, kProducerThreads> p;
for (auto& t : p) {
t = std::make_unique<std::thread>([&]() {
Expand Down

0 comments on commit 1d25907

Please sign in to comment.