rdf-benchmark 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 11b9b218709e7c01b2d0c924c058b8d934e3ac7b
4
+ data.tar.gz: bb4859eb9b2075ccd9178d6ab7ffd6439121b3fb
5
+ SHA512:
6
+ metadata.gz: 5d5c09fd5fd549d1d3f86f0bc933644b0afa455df95c3bf168cede0d6157d914e7a0bc41206aba5b3f752d1d7c561202be3666c52eade841d67df1b55312de50
7
+ data.tar.gz: c76b25a9f4137084d600688258ac8fc73757b1b7819997b69b89b4c2f61a1068bbb02c9347eb4dffa4eac4fc9b76ab995f6e78916ab7c8aac1ff951c48c67a93
data/AUTHORS ADDED
@@ -0,0 +1 @@
1
+ * Tom Johnson <n0reply@uw.edu>
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ RDF::Benchmark
2
+ ==============
3
+
4
+ [![Build Status](https://travis-ci.org/ruby-rdf/rdf.png?branch=master)](http://travis-ci.org/ruby-rdf/rdf-benchmark)
5
+
6
+ A benchmark framework for [RDF.rb](http://ruby-rdf.github.com/rdf).
7
+
8
+ ## Contributing
9
+
10
+ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange development and release activity. All submissions _must_ be on a feature branch based on the _develop_ branch to ease staging and integration.
11
+
12
+ * Do your best to adhere to the existing coding conventions and idioms.
13
+ * Don't use hard tabs, and don't leave trailing whitespace on any line.
14
+ Before committing, run `git diff --check` to make sure of this.
15
+ * Do document every method you add using [YARD][] annotations. Read the
16
+ [tutorial][YARD-GS] or just look at the existing code for examples.
17
+ * Don't touch the `.gemspec` or `VERSION` files. If you need to change them,
18
+ do so on your private branch only.
19
+ * Do feel free to add yourself to the `CREDITS` file and the
20
+ corresponding list in the the `README`. Alphabetical order applies.
21
+ * Don't touch the `AUTHORS` file. If your contributions are significant
22
+ enough, be assured we will eventually add you in there.
23
+ * Do note that in order for us to merge any non-trivial changes (as a rule
24
+ of thumb, additions larger than about 15 lines of code), we need an
25
+ explicit [public domain dedication][PDD] on record from you.
26
+
27
+ ## License
28
+
29
+ This is free and unencumbered public domain software. For more information,
30
+ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
31
+
data/UNLICENSE ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <http://unlicense.org/>
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+ require 'rdf/ntriples'
3
+
4
+ module RDF::Benchmark
5
+ ##
6
+ # @see http://wifo5-03.informatik.uni-mannheim.de/bizer/berlinsparqlbenchmark/spec/BenchmarkRules/index.html#datagenerator
7
+ class BerlinGenerator
8
+ DEFAULT_FILENAME = 'dataset'.freeze
9
+ DEFAULT_FACTOR = 2_000.freeze
10
+ DEFAULT_FORMAT = 'nt'.freeze
11
+ DEFAULT_PATH = './bsbmtools'.freeze
12
+
13
+ # @!attribute [rw] filename
14
+ # @!attribute [rw] product_factor
15
+ # @!attribute [rw] format
16
+ # @!attribute [rw] tool_path
17
+ attr_accessor :filename, :product_factor, :format, :tool_path
18
+
19
+ ##
20
+ # @param filename [String] (default: 'dataset')
21
+ # @param products [Integer] (default: 2000)
22
+ # @param format [String] (default: 'nt')
23
+ def initialize(filename: DEFAULT_FILENAME,
24
+ product_factor: DEFAULT_FACTOR,
25
+ format: DEFAULT_FORMAT,
26
+ tool_path: DEFAULT_PATH)
27
+ self.filename = filename
28
+ self.product_factor = product_factor
29
+ self.format = format
30
+ self.tool_path = tool_path
31
+ end
32
+
33
+ ##
34
+ # @return [RDF::Reader] a stream of the requested data
35
+ def data(&block)
36
+ filepath = Pathname.new(tool_path) + "#{filename}.#{format}"
37
+ generate_data! unless File.exists?(filepath)
38
+
39
+ RDF::Reader.open(filepath, &block)
40
+ end
41
+
42
+ ##
43
+ # Generates the data for this instance, writing it to disk.
44
+ #
45
+ # @return [Boolean] true if successful
46
+ #
47
+ # @note writes the output of the Berlin data generator to stdout
48
+ def generate_data!
49
+ start_dir = Dir.pwd
50
+
51
+ Dir.chdir tool_path
52
+ system "./generate -pc #{product_factor} -fn #{filename} -fc"
53
+ ensure
54
+ Dir.chdir start_dir
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+ module RDF::Benchmark
3
+ class Repository
4
+ # @!attribute [rw] repository
5
+ # @return [RDF::Repository] the repository to benchmark
6
+ attr_accessor :repository
7
+
8
+ ##
9
+ # @param generator [#data]
10
+ # @param repository [RDF::Repository] the repository to benchmark
11
+ def initialize(generator: , repository:)
12
+ @generator = generator
13
+ @repository = repository
14
+ end
15
+
16
+ ##
17
+ # @return [RDF::Enumerator]
18
+ def statements
19
+ @generator.data.each_statement
20
+ end
21
+
22
+ ##
23
+ # @param name [#to_s]
24
+ # @param count [Integer] number of statements to prime for insert
25
+ #
26
+ # @return [Benchmark::IPS::Report]
27
+ def insert!(name: 'insert', count: 100_000)
28
+ inserts = statements.lazy.take(count)
29
+
30
+ report = RDF::Benchmark.benchmark_ips!(name: name) do
31
+ repository.insert(inserts.next)
32
+ end
33
+
34
+ return report
35
+ ensure
36
+ repository.clear
37
+ end
38
+
39
+ ##
40
+ # @param name [#to_s] the name to give the benchmark report
41
+ # @param count [Integer] number of statements to prime for delete
42
+ #
43
+ # @return [Benchmark::IPS::Report]
44
+ def delete!(name: 'delete', count: 100_000)
45
+ deletes = statements.lazy.take(count)
46
+
47
+ deletes.each { |st| repository.insert(st) }
48
+
49
+ report = RDF::Benchmark.benchmark_ips!(name: name) do
50
+ repository.delete(deletes.next)
51
+ end
52
+
53
+ return report
54
+ ensure
55
+ repository.clear
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+ require 'rdf'
3
+ require 'benchmark/ips'
4
+
5
+ module RDF
6
+ module Benchmark
7
+ ##
8
+ # Benchmarks the given block, measuring iterations per second.
9
+ #
10
+ # @param name [String]
11
+ # @param time [Integer]
12
+ # @param warmup [Integer]
13
+ # @yield runs the block repeatedly as a Benchmark#ips report
14
+ #
15
+ # @return [Benchmark::IPS::Report]
16
+ # @see Benchmark#ips
17
+ def self.benchmark_ips!(name: , time: 5, warmup: 2, &block)
18
+ ::Benchmark.ips do |bm|
19
+ bm.config(:time => time, :warmup => warmup)
20
+ bm.report(name, &block)
21
+ end
22
+ end
23
+
24
+ ##
25
+ # Benchmarks a single run of the given block (with warmup).
26
+ #
27
+ # @param name [String]
28
+ # @yield runs the block as a Benchmark#bmbm report
29
+ #
30
+ # @return [Benchmark::Report]
31
+ # @see Benchmark#bmbm
32
+ def self.benchmark!(name:, &block)
33
+ ::Benchmark.bmbm do |bm|
34
+ bm.report(name, &block)
35
+ end
36
+ end
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rdf-benchmark
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Tom Johnson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rdf
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: benchmark-ips
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '2.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '2.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0.8'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0.8'
83
+ description: Dataset Generation & Benchmarks for RDF.rb
84
+ email: public-rdf-ruby@w3.org
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - AUTHORS
90
+ - README.md
91
+ - UNLICENSE
92
+ - VERSION
93
+ - lib/rdf/benchmark.rb
94
+ - lib/rdf/benchmark/berlin_generator.rb
95
+ - lib/rdf/benchmark/repository.rb
96
+ homepage: http://ruby-rdf.github.com/rdf-benchmark
97
+ licenses:
98
+ - Public Domain
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: 2.0.0
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.5.1
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Dataset Generation & Benchmarks for RDF.rb
120
+ test_files: []
121
+ has_rdoc: false