diff --git a/benchmarks/defined_types4/benchmarker.rb b/benchmarks/defined_types4/benchmarker.rb new file mode 100644 index 000000000..5b0669291 --- /dev/null +++ b/benchmarks/defined_types4/benchmarker.rb @@ -0,0 +1,73 @@ +require 'erb' +require 'ostruct' +require 'fileutils' +require 'json' + +class Benchmarker + include FileUtils + + def initialize(target, size) + @target = target + @size = size + end + + def setup + require 'puppet' + config = File.join(@target, 'puppet.conf') + Puppet.initialize_settings(['--config', config]) + end + + def run(args=nil) + env = Puppet.lookup(:environments).get('benchmarking') + node = Puppet::Node.new("testing", :environment => env) + Puppet::Resource::Catalog.indirection.find("testing", :use_node => node) + end + + def generate + environment = File.join(@target, 'environments', 'benchmarking') + templates = File.join('benchmarks', 'defined_types4') + + mkdir_p(File.join(environment, 'modules')) + mkdir_p(File.join(environment, 'manifests')) + + render(File.join(templates, 'site.pp.erb'), + File.join(environment, 'manifests', 'site.pp'), + :size => @size) + + @size.times do |i| + module_name = "module#{i}" + module_base = File.join(environment, 'modules', module_name) + manifests = File.join(module_base, 'manifests') + + mkdir_p(manifests) + + File.open(File.join(module_base, 'metadata.json'), 'w') do |f| + JSON.dump({ + "types" => [], + "source" => "", + "author" => "Defined Types Benchmark Future Parser", + "license" => "Apache 2.0", + "version" => "1.0.0", + "description" => "Defined Types benchmark module #{i}", + "summary" => "Just this benchmark module, you know?", + "dependencies" => [], + }, f) + end + + render(File.join(templates, 'module', 'testing.pp.erb'), + File.join(manifests, 'testing.pp'), + :name => module_name) + end + + render(File.join(templates, 'puppet.conf.erb'), + File.join(@target, 'puppet.conf'), + :location => @target) + end + + def render(erb_file, output_file, bindings) + site = ERB.new(File.read(erb_file)) + File.open(output_file, 'w') do |fh| + fh.write(site.result(OpenStruct.new(bindings).instance_eval { binding })) + end + end +end diff --git a/benchmarks/defined_types4/description b/benchmarks/defined_types4/description new file mode 100644 index 000000000..f24e9bba4 --- /dev/null +++ b/benchmarks/defined_types4/description @@ -0,0 +1,4 @@ +Benchmark scenario: heavy use of defined types future parser +Benchmark target: catalog compilation +Parser: Future + diff --git a/benchmarks/defined_types4/module/testing.pp.erb b/benchmarks/defined_types4/module/testing.pp.erb new file mode 100644 index 000000000..e723561d5 --- /dev/null +++ b/benchmarks/defined_types4/module/testing.pp.erb @@ -0,0 +1,3 @@ +define <%= name %>::testing { + notify { "in <%= name %>: $title": } +} diff --git a/benchmarks/defined_types4/puppet.conf.erb b/benchmarks/defined_types4/puppet.conf.erb new file mode 100644 index 000000000..618ea6e2f --- /dev/null +++ b/benchmarks/defined_types4/puppet.conf.erb @@ -0,0 +1,4 @@ +confdir = <%= location %> +vardir = <%= location %> +environmentpath = <%= File.join(location, 'environments') %> +parser = future diff --git a/benchmarks/defined_types4/site.pp.erb b/benchmarks/defined_types4/site.pp.erb new file mode 100644 index 000000000..338b635b2 --- /dev/null +++ b/benchmarks/defined_types4/site.pp.erb @@ -0,0 +1,4 @@ +<% size.times do |i| %> + module<%= i %>::testing { "first": } + module<%= i %>::testing{ "second": } +<% end %> diff --git a/benchmarks/empty_catalog/benchmarker.rb b/benchmarks/empty_catalog/benchmarker.rb new file mode 100644 index 000000000..809685cc2 --- /dev/null +++ b/benchmarks/empty_catalog/benchmarker.rb @@ -0,0 +1,47 @@ +require 'erb' +require 'ostruct' +require 'fileutils' +require 'json' + +class Benchmarker + include FileUtils + + def initialize(target, size) + @target = target + @size = size + end + + def setup + require 'puppet' + config = File.join(@target, 'puppet.conf') + Puppet.initialize_settings(['--config', config]) + end + + def run(args=nil) + env = Puppet.lookup(:environments).get('benchmarking') + node = Puppet::Node.new("testing", :environment => env) + Puppet::Resource::Catalog.indirection.find("testing", :use_node => node) + end + + def generate + environment = File.join(@target, 'environments', 'benchmarking') + templates = File.join('benchmarks', 'empty_catalog') + + mkdir_p(File.join(environment, 'modules')) + mkdir_p(File.join(environment, 'manifests')) + + render(File.join(templates, 'site.pp.erb'), + File.join(environment, 'manifests', 'site.pp'),{}) + + render(File.join(templates, 'puppet.conf.erb'), + File.join(@target, 'puppet.conf'), + :location => @target) + end + + def render(erb_file, output_file, bindings) + site = ERB.new(File.read(erb_file)) + File.open(output_file, 'w') do |fh| + fh.write(site.result(OpenStruct.new(bindings).instance_eval { binding })) + end + end +end diff --git a/benchmarks/empty_catalog/description b/benchmarks/empty_catalog/description new file mode 100644 index 000000000..d06e41b82 --- /dev/null +++ b/benchmarks/empty_catalog/description @@ -0,0 +1,4 @@ +Benchmark scenario: an empty catalog (only one call to log a message) shows the setup time for env / compiler +Benchmark target: catalog compilation overhead +Parser: Future + diff --git a/benchmarks/empty_catalog/puppet.conf.erb b/benchmarks/empty_catalog/puppet.conf.erb new file mode 100644 index 000000000..00e2986bf --- /dev/null +++ b/benchmarks/empty_catalog/puppet.conf.erb @@ -0,0 +1,5 @@ +confdir = <%= location %> +vardir = <%= location %> +environmentpath = <%= File.join(location, 'environments') %> +environment_timeout = '0' +parser = future diff --git a/benchmarks/empty_catalog/site.pp.erb b/benchmarks/empty_catalog/site.pp.erb new file mode 100644 index 000000000..054628183 --- /dev/null +++ b/benchmarks/empty_catalog/site.pp.erb @@ -0,0 +1 @@ +notice('hello world') \ No newline at end of file