Skip to content

Commit

Permalink
delete all duplicate empty blanks (#5758)
Browse files Browse the repository at this point in the history
Signed-off-by: Xiang Dai <764524258@qq.com>
  • Loading branch information
daixiang0 authored and BSBandme committed Feb 21, 2019
1 parent c691c4c commit e479410
Show file tree
Hide file tree
Showing 141 changed files with 984 additions and 984 deletions.
32 changes: 16 additions & 16 deletions benchmarks/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ java_benchmark_testing_files = \
java/src/main/java/com/google/protobuf/ProtoCaliperBenchmark.java

javac_middleman: $(java_benchmark_testing_files) protoc_middleman protoc_middleman2
cp -r $(srcdir)/java tmp
cp -r $(srcdir)/java tmp
mkdir -p tmp/java/lib
cp $(top_srcdir)/java/core/target/*.jar tmp/java/lib/protobuf-java.jar
cd tmp/java && mvn clean compile assembly:single -Dprotobuf.version=$(PACKAGE_VERSION) && cd ../..
Expand Down Expand Up @@ -253,7 +253,7 @@ go_protoc_middleman: make_tmp_dir $(top_srcdir)/src/protoc$(EXEEXT) $(benchmarks
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --go_out=$$oldpwd/tmp $(benchmarks_protoc_inputs_proto2_message4) )
touch go_protoc_middleman

go-benchmark: go_protoc_middleman
go-benchmark: go_protoc_middleman
@echo "Writing shortcut script go-benchmark..."
@echo '#! /bin/bash' > go-benchmark
@echo 'cd $(srcdir)/go' >> go-benchmark
Expand All @@ -265,7 +265,7 @@ go-benchmark: go_protoc_middleman
@echo 'cd ..' >> go-benchmark
@chmod +x go-benchmark

go: go_protoc_middleman go-benchmark
go: go_protoc_middleman go-benchmark
./go-benchmark $(all_data)

############# GO RULES END ##############
Expand Down Expand Up @@ -322,9 +322,9 @@ $(cpp_no_group_benchmarks_protoc_outputs_proto2_header): cpp_no_group_protoc_mid
generate_cpp_no_group_benchmark_code:
cp $(srcdir)/cpp/cpp_benchmark.cc gogo/cpp_no_group/cpp_benchmark.cc
sed -i -e "s/\#include \"datasets/\#include \"gogo\/cpp_no_group\/datasets/g" gogo/cpp_no_group/cpp_benchmark.cc
sed -i -e "s/\#include \"benchmarks.pb.h/\#include \"gogo\/cpp_no_group\/benchmarks.pb.h/g" gogo/cpp_no_group/cpp_benchmark.cc
sed -i -e "s/\#include \"benchmarks.pb.h/\#include \"gogo\/cpp_no_group\/benchmarks.pb.h/g" gogo/cpp_no_group/cpp_benchmark.cc
touch generate_cpp_no_group_benchmark_code

bin_PROGRAMS += cpp-no-group-benchmark
cpp_no_group_benchmark_LDADD = $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/third_party/benchmark/src/libbenchmark.a
cpp_no_group_benchmark_SOURCES = gogo/cpp_no_group/cpp_benchmark.cc
Expand All @@ -343,7 +343,7 @@ nodist_cpp_no_group_benchmark_SOURCES = \

cpp_no_group: cpp_no_group_protoc_middleman generate_gogo_data cpp-no-group-benchmark
./cpp-no-group-benchmark $(gogo_data)

gogo_proto_middleman: protoc-gen-gogoproto
mkdir -p "tmp/gogo_proto"
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I$(srcdir) -I$(top_srcdir) --plugin=protoc-gen-gogoproto --gogoproto_out=$$oldpwd/tmp/gogo_proto $(benchmarks_protoc_inputs) $(benchmarks_protoc_inputs_benchmark_wrapper) $(benchmarks_protoc_inputs_proto2) )
Expand All @@ -355,7 +355,7 @@ generate_gogo_data: protoc_middleman protoc_middleman2 gogo-data-scrubber
mkdir -p `dirname $(gogo_data)`
./gogo-data-scrubber $(all_data) $(gogo_data)
touch generate_gogo_data

make_tmp_dir_gogo:
mkdir -p tmp/go_no_group/benchmark_code
mkdir -p tmp/gogofast/benchmark_code
Expand Down Expand Up @@ -435,10 +435,10 @@ gogo-benchmark:

go_no_group: go_no_group_protoc_middleman generate_gogo_data generate_all_gogo_benchmark_code gogo-benchmark
./gogo-benchmark go_no_group $(gogo_data)
gogofast: gogofast_protoc_middleman generate_gogo_data gogo-benchmark generate_all_gogo_benchmark_code

gogofast: gogofast_protoc_middleman generate_gogo_data gogo-benchmark generate_all_gogo_benchmark_code
./gogo-benchmark gogofast $(gogo_data)

gogofaster: gogofaster_protoc_middleman generate_gogo_data gogo-benchmark generate_all_gogo_benchmark_code
./gogo-benchmark gogofaster $(gogo_data)

Expand All @@ -448,7 +448,7 @@ gogoslick: gogoslick_protoc_middleman generate_gogo_data gogo-benchmark generat

############# GOGO RULES END ############


############ UTIL RULES BEGIN ############

bin_PROGRAMS += protoc-gen-gogoproto gogo-data-scrubber protoc-gen-proto2_to_proto3 proto3-data-stripper
Expand Down Expand Up @@ -481,7 +481,7 @@ nodist_proto3_data_stripper_SOURCES = \
$(benchmarks_protoc_outputs_proto2_header) \
$(benchmarks_protoc_outputs_header)


############ UTIL RULES END ############

############ PROTO3 PREPARATION BEGIN #############
Expand Down Expand Up @@ -510,7 +510,7 @@ proto3_middleman_php: proto3_proto_middleman

php-benchmark: proto3_middleman_php generate_proto3_data
mkdir -p "tmp/php/Google/Protobuf/Benchmark" && cp php/PhpBenchmark.php "tmp/php/Google/Protobuf/Benchmark"
cp php/autoload.php "tmp/php"
cp php/autoload.php "tmp/php"
@echo "Writing shortcut script php-benchmark..."
@echo '#! /bin/bash' > php-benchmark
@echo 'export PROTOBUF_PHP_SRCDIR="$$(cd $(top_srcdir) && pwd)/php/src"' >> php-benchmark
Expand All @@ -527,8 +527,8 @@ php_c_extension:
cd $(top_srcdir)/php/ext/google/protobuf && phpize && ./configure CFLAGS='-O3' && make -j8

php-c-benchmark: proto3_middleman_php generate_proto3_data php_c_extension php_c_extension
mkdir -p "tmp/php/Google/Protobuf/Benchmark" && cp php/PhpBenchmark.php "tmp/php/Google/Protobuf/Benchmark"
cp php/autoload.php "tmp/php"
mkdir -p "tmp/php/Google/Protobuf/Benchmark" && cp php/PhpBenchmark.php "tmp/php/Google/Protobuf/Benchmark"
cp php/autoload.php "tmp/php"
@echo "Writing shortcut script php-c-benchmark..."
@echo '#! /bin/bash' > php-c-benchmark
@echo 'export PROTOBUF_PHP_SRCDIR="$$(cd $(top_srcdir) && pwd)/php/src"' >> php-c-benchmark
Expand Down Expand Up @@ -654,4 +654,4 @@ CLEANFILES = \

clean-local:
-rm -rf tmp/*

8 changes: 4 additions & 4 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

This directory contains benchmarking schemas and data sets that you
can use to test a variety of performance scenarios against your
protobuf language runtime. If you are looking for performance
protobuf language runtime. If you are looking for performance
numbers of officially support languages, see [here](
https://github.com/protocolbuffers/protobuf/blob/master/docs/performance.md)

Expand Down Expand Up @@ -45,8 +45,8 @@ And you also need to make sure `pkg-config` is installed.

### Go
Go protobufs are maintained at [github.com/golang/protobuf](
http://github.com/golang/protobuf). If not done already, you need to install the
toolchain and the Go protoc-gen-go plugin for protoc.
http://github.com/golang/protobuf). If not done already, you need to install the
toolchain and the Go protoc-gen-go plugin for protoc.

To install protoc-gen-go, run:

Expand All @@ -59,7 +59,7 @@ The first command installs `protoc-gen-go` into the `bin` directory in your loca
The second command adds the `bin` directory to your `PATH` so that `protoc` can locate the plugin later.

### PHP
PHP benchmark's requirement is the same as PHP protobuf's requirements. The benchmark will automaticly
PHP benchmark's requirement is the same as PHP protobuf's requirements. The benchmark will automaticly
include PHP protobuf's src and build the c extension if required.

### Node.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import java.util.List;

// Caliper set CICompilerCount to 1 for making sure compilation doesn't run in parallel with itself,
// This makes TieredCompilation not working. We just disable TieredCompilation by default. In master
// branch this has been disabled by default in caliper:
// This makes TieredCompilation not working. We just disable TieredCompilation by default. In master
// branch this has been disabled by default in caliper:
// https://github.com/google/caliper/blob/master/caliper-runner/src/main/java/com/google/caliper/runner/target/Jvm.java#L38:14
// But this haven't been added into most recent release.
@VmOptions("-XX:-TieredCompilation")
Expand Down Expand Up @@ -89,15 +89,15 @@ Message getDefaultInstance() {
return com.google.protobuf.benchmarks.BenchmarkMessage4.GoogleMessage4.getDefaultInstance();
}
};

abstract ExtensionRegistry getExtensionRegistry();
abstract Message getDefaultInstance();
}

private BenchmarkMessageType benchmarkMessageType;
@Param("")
private String dataFile;

private byte[] inputData;
private BenchmarkDataset benchmarkDataset;
private Message defaultMessage;
Expand Down Expand Up @@ -125,7 +125,7 @@ private BenchmarkMessageType getMessageType() throws IOException {
+ benchmarkDataset.getMessageName());
}
}

@BeforeExperiment
void setUp() throws IOException {
if (!dataFile.equals("")) {
Expand All @@ -145,7 +145,7 @@ void setUp() throws IOException {
inputStreamList = new ArrayList<ByteArrayInputStream>();
inputStringList = new ArrayList<ByteString>();
sampleMessageList = new ArrayList<Message>();

for (int i = 0; i < benchmarkDataset.getPayloadCount(); i++) {
byte[] singleInputData = benchmarkDataset.getPayload(i).toByteArray();
inputDataList.add(benchmarkDataset.getPayload(i).toByteArray());
Expand All @@ -156,20 +156,20 @@ void setUp() throws IOException {
defaultMessage.newBuilderForType().mergeFrom(singleInputData, extensions).build());
}
}


@Benchmark
void serializeToByteArray(int reps) throws IOException {
if (sampleMessageList.size() == 0) {
return;
}
for (int i = 0; i < reps; i++) {
for (int j = 0; j < sampleMessageList.size(); j++) {
sampleMessageList.get(j).toByteArray();
sampleMessageList.get(j).toByteArray();
}
}
}

@Benchmark
void serializeToMemoryStream(int reps) throws IOException {
if (sampleMessageList.size() == 0) {
Expand All @@ -178,11 +178,11 @@ void serializeToMemoryStream(int reps) throws IOException {
for (int i = 0; i < reps; i++) {
for (int j = 0; j < sampleMessageList.size(); j++) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
sampleMessageList.get(j).writeTo(output);
sampleMessageList.get(j).writeTo(output);
}
}
}

@Benchmark
void deserializeFromByteArray(int reps) throws IOException {
if (inputDataList.size() == 0) {
Expand All @@ -195,7 +195,7 @@ void deserializeFromByteArray(int reps) throws IOException {
}
}
}

@Benchmark
void deserializeFromMemoryStream(int reps) throws IOException {
if (inputStreamList.size() == 0) {
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/js/benchmark_suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function newBenchmark(messageName, filename, language) {
})
.on("start", function() {
process.stdout.write(
"benchmarking message " + messageName
+ " of dataset file " + filename
"benchmarking message " + messageName
+ " of dataset file " + filename
+ "'s performance ..." + "\n\n");
})
.on("cycle", function(event) {
Expand All @@ -21,7 +21,7 @@ function newBenchmark(messageName, filename, language) {
return 1 / (bench.stats.mean + bench.stats.moe);
}
benches.forEach(function(val, index) {
benches[index] = getHz(val);
benches[index] = getHz(val);
});
}),
benches: benches
Expand Down
12 changes: 6 additions & 6 deletions benchmarks/js/js_benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ process.argv.forEach(function(filename, index) {
json_file = filename.replace(/^--json_output=/, '');
return;
}

var benchmarkDataset =
proto.benchmarks.BenchmarkDataset.deserializeBinary(fs.readFileSync(filename));
var messageList = [];
Expand All @@ -40,22 +40,22 @@ process.argv.forEach(function(filename, index) {
messageList.push(message.deserializeBinary(onePayload));
totalBytes += onePayload.length;
});

var senarios = benchmarkSuite.newBenchmark(
benchmarkDataset.getMessageName(), filename, "js");
senarios.suite
.add("js deserialize", function() {
benchmarkDataset.getPayloadList().forEach(function(onePayload) {
var protoType = getNewPrototype(benchmarkDataset.getMessageName());
protoType.deserializeBinary(onePayload);
});
});
})
.add("js serialize", function() {
var protoType = getNewPrototype(benchmarkDataset.getMessageName());
messageList.forEach(function(message) {
message.serializeBinary();
});
})
})
.run({"Async": false});

results.push({
Expand All @@ -66,9 +66,9 @@ process.argv.forEach(function(filename, index) {
}
})

console.log("Throughput for deserialize: "
console.log("Throughput for deserialize: "
+ senarios.benches[0] * totalBytes / 1024 / 1024 + "MB/s" );
console.log("Throughput for serialize: "
console.log("Throughput for serialize: "
+ senarios.benches[1] * totalBytes / 1024 / 1024 + "MB/s" );
console.log("");
});
Expand Down
14 changes: 7 additions & 7 deletions benchmarks/php/PhpBenchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static function parse(&$args) {
(new $args[1]())->mergeFromString($payloads->offsetGet($i));
}
}

// $args: array of message
static function serialize(&$args) {
foreach ($args as &$temp_message) {
Expand All @@ -49,7 +49,7 @@ class Benchmark
private $benchmark_time;
private $total_bytes;
private $coefficient;

public function __construct($benchmark_name, $args, $total_bytes,
$benchmark_time = 5.0) {
$this->args = $args;
Expand All @@ -58,15 +58,15 @@ public function __construct($benchmark_name, $args, $total_bytes,
$this->total_bytes = $total_bytes;
$this->coefficient = pow (10, 0) / pow(2, 20);
}

public function runBenchmark() {
$t = $this->runBenchmarkWithTimes(1);
$times = ceil($this->benchmark_time / $t);
return $this->total_bytes * $times /
($times == 1 ? $t : $this->runBenchmarkWithTimes($times)) *
$this->coefficient;
}

private function runBenchmarkWithTimes($times) {
$st = microtime(true);
for ($i = 0; $i < $times; $i++) {
Expand Down Expand Up @@ -109,14 +109,14 @@ function runBenchmark($file, $behavior_prefix) {
array_push($message_list, $new_message);
$total_bytes += strlen($payloads->offsetGet($i));
}

$parse_benchmark = new Benchmark(
"\Google\Protobuf\Benchmark\BenchmarkMethod::parse",
array($dataset, $message_name), $total_bytes);
$serialize_benchmark = new Benchmark(
"\Google\Protobuf\Benchmark\BenchmarkMethod::serialize",
$message_list, $total_bytes);

return array(
"filename" => $file,
"benchmarks" => array(
Expand All @@ -139,7 +139,7 @@ function runBenchmark($file, $behavior_prefix) {
if ($arg == "--json") {
$json_output = true;
} else if (strpos($arg, "--behavior_prefix") == 0) {
$behavior_prefix = str_replace("--behavior_prefix=", "", $arg);
$behavior_prefix = str_replace("--behavior_prefix=", "", $arg);
}
}

Expand Down
Loading

0 comments on commit e479410

Please sign in to comment.