Skip to content
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
2 changes: 2 additions & 0 deletions benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ blurhash:
desc: blurhash (blurred preview image) calculation
protoboeuf:
desc: protoboeuf (pure-Ruby protobuf) message decoding
protoboeuf-encode:
desc: protoboeuf (pure-Ruby protobuf) message encoding

#
# MicroBenchmarks
Expand Down
124 changes: 124 additions & 0 deletions benchmarks/protoboeuf-encode/benchmark.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
syntax = "proto3";

package upstream;

//
// This aims to be a larger, more representative benchmark
// The messages intentionally use nesting and have many fields of
// multiple different types.
//

message Position
{
uint32 x = 1;
uint32 y = 2;
uint32 z = 3;
}

message TrunkItem
{
enum ITEM_TYPE {
LAPTOP = 0;
DUFFEL_BAG = 1;
GOLF_CLUBS = 2;
BASEBALL_BAT = 3;
SUITCASE = 4;
BRICKS = 5;
CROWBAR = 6;
CASH = 7;
POKEMON_CARDS = 8;
}

enum COUNTRY {
NOT_US_OF_A = 0; // Zero
US_OF_A = 1; // Number 1
CANADA = 2;
}

string id = 1;
string owner_id = 2;
COUNTRY made_in = 3;
uint64 width = 4;
uint64 height = 5;
uint64 depth = 6;
uint64 weight = 7;
bool is_usbc = 8;
Position pos = 9;
bool is_umbrella = 10;
double monetary_value = 11;
ITEM_TYPE item_type = 12;
}

message Vehicle
{
enum VEHICLE_TYPE {
CAR = 0;
SPORTS_CAR = 1;
SUV = 2;
PICKUP_TRUCK = 3;
MINIVAN = 4;
MOTORCYCLE = 5;
}

uint64 id = 1;
string make = 2;
string model = 3;
uint64 owner_id = 4;
uint32 year = 5;
VEHICLE_TYPE type = 6;

bool is_electric = 7;
uint32 num_doors = 8;
uint32 num_wheels = 9;
uint32 num_windows = 10;
uint32 wheel_size = 11;

uint64 dry_weight = 12;
uint64 trunk_volume = 13;
double monetary_value = 14;

// List of items in the trunk
repeated TrunkItem trunk_items = 15;

bool is_manual = 16;
}

message ParkingSpace
{
Position pos = 1;
bool has_electric_charger = 2;
bool handicapped = 3;
optional Vehicle vehicle = 4;
}

message ParkingFloor
{
uint64 id = 1;

uint32 num_cameras = 4;
uint32 num_fire_exits = 5;
uint32 num_sprinklers = 6;
double area_sqft = 7;

// inches because 'Murica
// Also we don't want too many doubles because that
// wouldn't be representative of most real-world use cases
uint32 ceiling_height_inches = 8;

// List of vehicles
repeated ParkingSpace parking_spaces = 9;
}

message ParkingLot
{
string name = 1;
string district = 2;
string phone_number = 3;
uint64 id = 4;
uint32 num_floors = 5;
uint32 num_entrances = 6;
uint32 num_attendants = 7;

// List of floors
repeated ParkingFloor floors = 8;
}
12 changes: 12 additions & 0 deletions benchmarks/protoboeuf-encode/benchmark.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require_relative '../../harness/loader'

# Protoboeuf decoder
require_relative 'benchmark_pb'

Dir.chdir __dir__
fake_msg_bins = Marshal.load(File.binread('encoded_msgs.bin'))
lots = fake_msg_bins.map { |bin| ProtoBoeuf::ParkingLot.decode bin }

run_benchmark(20) do
lots.each { |lot| ProtoBoeuf::ParkingLot.encode lot }
end
Loading