Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm: remove non-representative and redundant benchmarks. #15203

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 15 additions & 39 deletions test/extensions/bootstrap/wasm/test_data/speed_cpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ START_WASM_PLUGIN(WasmSpeedCpp)

int xDoNotRemove = 0;

google::protobuf::Arena arena;
google::protobuf::Struct test_proto;

google::protobuf::Struct args;
google::protobuf::Struct* args_arena =
google::protobuf::Arena::CreateMessage<google::protobuf::Struct>(&arena);
std::string configuration = R"EOF(
const std::string test_json = R"EOF(
{
"NAME":"test_pod",
"NAMESPACE":"test_namespace",
Expand All @@ -43,9 +40,6 @@ std::string configuration = R"EOF(
}
)EOF";

// google::protobuf::Struct a;
// google::protobuf::util::JsonStringToMessage(configuration+'hfdjfhkjhdskhjk', a);

const static char encodeLookup[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const static char padCharacter = '=';
Expand Down Expand Up @@ -242,47 +236,34 @@ void modify_metadata1000_test() {
}
}

void json_serialize_test() { google::protobuf::util::JsonStringToMessage(configuration, &args); }

void json_serialize_arena_test() {
google::protobuf::util::JsonStringToMessage(configuration, args_arena);
void json_serialize_test() {
google::protobuf::Struct proto;
google::protobuf::util::JsonStringToMessage(test_json, &proto);
}

void json_deserialize_test() {
std::string json;
google::protobuf::util::MessageToJsonString(args, &json);
google::protobuf::util::MessageToJsonString(test_proto, &json);
xDoNotRemove += json.size();
}

void json_deserialize_arena_test() {
std::string json;
google::protobuf::util::MessageToJsonString(*args_arena, &json);
}

void json_deserialize_empty_test() {
std::string json;
google::protobuf::Struct empty;
google::protobuf::util::MessageToJsonString(empty, &json);
xDoNotRemove = json.size();
}

void json_serialize_deserialize_test() {
std::string json;
google::protobuf::Struct proto;
google::protobuf::util::JsonStringToMessage(configuration, &proto);
google::protobuf::util::MessageToJsonString(proto, &json);
xDoNotRemove = json.size();
}

void convert_to_filter_state_test() {
auto start = reinterpret_cast<uint8_t*>(&*configuration.begin());
auto end = start + configuration.size();
std::string encoded_config = base64Encode(start, end);
auto start = reinterpret_cast<const uint8_t*>(&*test_json.begin());
auto end = start + test_json.size();
std::string encoded_json = base64Encode(start, end);
std::vector<uint8_t> decoded;
base64Decode(encoded_config, &decoded);
std::string decoded_config(decoded.begin(), decoded.end());
google::protobuf::util::JsonStringToMessage(decoded_config, &args);
auto bytes = args.SerializeAsString();
base64Decode(encoded_json, &decoded);
std::string decoded_json(decoded.begin(), decoded.end());
google::protobuf::Struct proto;
google::protobuf::util::JsonStringToMessage(decoded_json, &proto);
auto bytes = proto.SerializeAsString();
setFilterStateStringValue("wasm_request_set_key", bytes);
}

Expand Down Expand Up @@ -320,16 +301,11 @@ WASM_EXPORT(uint32_t, proxy_on_vm_start, (uint32_t, uint32_t configuration_size)
test_fn = &modify_metadata1000_test;
} else if (configuration == "json_serialize") {
test_fn = &json_serialize_test;
} else if (configuration == "json_serialize_arena") {
test_fn = &json_serialize_arena_test;
} else if (configuration == "json_deserialize") {
google::protobuf::util::JsonStringToMessage(test_json, &test_proto);
test_fn = &json_deserialize_test;
} else if (configuration == "json_deserialize_empty") {
test_fn = &json_deserialize_empty_test;
} else if (configuration == "json_deserialize_arena") {
test_fn = &json_deserialize_arena_test;
} else if (configuration == "json_serialize_deserialize") {
test_fn = &json_serialize_deserialize_test;
} else if (configuration == "convert_to_filter_state") {
test_fn = &convert_to_filter_state_test;
} else {
Expand Down
3 changes: 0 additions & 3 deletions test/extensions/bootstrap/wasm/wasm_speed_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,8 @@ B(grpc_service1000)
B(modify_metadata)
B(modify_metadata1000)
B(json_serialize)
B(json_serialize_arena)
B(json_deserialize)
B(json_deserialize_arena)
B(json_deserialize_empty)
B(json_serialize_deserialize)
B(convert_to_filter_state)

} // namespace Wasm
Expand Down