Skip to content

Instantly share code, notes, and snippets.

@philwo
Created November 30, 2016 14:20
Show Gist options
  • Save philwo/bf9c79c5f13fc11be72fa4c78fb1286d to your computer and use it in GitHub Desktop.
Save philwo/bf9c79c5f13fc11be72fa4c78fb1286d to your computer and use it in GitHub Desktop.
Bazel benchmark for sandboxing performance
# Benchmarks for sandbox performance
#
# Run with 'bazel build :gen_main' and measure the time it takes.
# Creates 15000 input files.
inputs = ["input_%s" % i for i in range(15000)]
genrule(
name = "gen_inputs",
outs = inputs,
cmd = "date | tee $(OUTS) > /dev/null",
)
# Create 100 rules that depend on the input files.
genrules = ["genrule_%s" % i for i in range(100)]
[genrule(
name = "gen_%s" % name,
srcs = inputs,
outs = [name],
cmd = "cat $(SRCS) > \"$@\"",
) for name in genrules]
# One rule to rule them all in a final step.
genrule(
name = "gen_main",
srcs = genrules,
outs = ["main"],
cmd = "cat $(SRCS) > \"$@\"",
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment