Skip to content

Commit

Permalink
Clean things up, add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
George Gensure committed Apr 12, 2019
1 parent 6c194c4 commit fedbf69
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 5 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Generates a desired number of actions according to a linear noise
shape profile. The generated actions consume a deterministic amount
of cpu time and depend on zero or one targets in order to establish
their position in the overall organization of the build graph.

To generate:

bazel run tools:gen [shamt] [desired_targets] > BUILD

*shamt* is a power-of-2 degree of the linear noise generated. The higher
the *shamt*, the more levels to the graph.

*desired_targets* is a total count of targets that should be generated.
This is desired, not exact, and may shift slightly to ensure no empty
levels.

To exercise:

bazel build :all

Shortest time for a given parameter set wins.

Feel free to use any options you want to improve your score.
13 changes: 13 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
patches = ["//third_party:rules_ruby.patch"],
name = "com_github_yugui_rules_ruby",
sha256 = "868f7f7ff48af995ca5197a981baef717315e44b2ca0d52f01c2ccf50f3b9f33",
strip_prefix = "rules_ruby-7771813c532e51367e25f9b3928822aad06d2183",
url = "https://github.com/yugui/rules_ruby/archive/7771813c532e51367e25f9b3928822aad06d2183.zip",
)

load("@com_github_yugui_rules_ruby//ruby:def.bzl", "ruby_register_toolchains")

ruby_register_toolchains()
Empty file added third_party/BUILD
Empty file.
22 changes: 22 additions & 0 deletions third_party/rules_ruby.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- ruby/private/library.bzl 2019-04-12 14:28:59.026302254 -0400
+++ ruby/private/library.bzl 2019-04-12 14:29:02.890307286 -0400
@@ -38,7 +38,7 @@
),
"data": attr.label_list(
allow_files = True,
- cfg = "data",
+ cfg = "host",
),
},
)
--- ruby/private/binary.bzl.orig 2019-04-12 14:33:22.042642589 -0400
+++ ruby/private/binary.bzl 2019-04-12 14:33:11.854629476 -0400
@@ -65,7 +65,7 @@
"rubyopt": attr.string_list(),
"data": attr.label_list(
allow_files = True,
- cfg = "data",
+ cfg = "host",
),
"main": attr.label(
allow_single_file = True,
9 changes: 9 additions & 0 deletions tools/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
load("@com_github_yugui_rules_ruby//ruby:def.bzl", "ruby_binary")

cc_binary(
name = "ex",
srcs = ["ex.c"],
visibility = ["//visibility:public"],
)

ruby_binary(
name = "gen",
srcs = ["gen.rb"],
visibility = ["//visibility:public"],
data = ["package.erb", "target.erb"],
)
13 changes: 8 additions & 5 deletions gen.rb → tools/gen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(rule, name, deps)
@deps = deps
end

TEMPLATE = File.read("target.erb")
TEMPLATE = File.read("tools/target.erb")

def self.renderer
@erb ||= ERB.new(TEMPLATE, safe_level=nil, trim_mode=?-)
Expand Down Expand Up @@ -52,7 +52,7 @@ def initialize(targets)
@targets = targets
end

TEMPLATE = File.read("package.erb")
TEMPLATE = File.read("tools/package.erb")

def self.renderer
@erb ||= ERB.new(TEMPLATE, safe_level=nil, trim_mode=?-)
Expand Down Expand Up @@ -104,7 +104,7 @@ def sum

def generate
@keypoints[0] = rand
@keypoints[1 << @shift]
@keypoints[1 << @shift] = rand

generate_at(1 << (@shift - 1), 1 << (@shift - 1), 1.0)

Expand All @@ -126,9 +126,12 @@ def generate_at(at, length, scale)
end
end

noise = LinearNoise.new(7)
shift = ARGV[0].to_i
desired_actions = ARGV[1].to_i

noise_factor = ((100000 - noise.size) / noise.sum)
noise = LinearNoise.new(shift)

noise_factor = ((desired_actions - noise.size) / noise.sum)

package_builder = Package::Builder.new

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit fedbf69

Please sign in to comment.