Module: Classbench
- Defined in:
- lib/classbench.rb,
lib/classbench/rule.rb,
lib/classbench/trie.rb,
lib/classbench/analyser.rb
Defined Under Namespace
Classes: Analyser, ClassbenchStats, NodeStats, Rule, Trie, TrieStats
Constant Summary
collapse
- DEFAULT_DEPTH =
32
Class Method Summary
collapse
Class Method Details
.analyse(filename) ⇒ Object
30
31
32
33
34
|
# File 'lib/classbench.rb', line 30
def self.analyse(filename)
analyser = Analyser.new
analyser.parse_openflow(File.read(filename))
100.times { p analyser.generate }
end
|
.generate_prefix ⇒ Object
9
10
11
12
13
|
# File 'lib/classbench.rb', line 9
def self.generate_prefix
len = rand(33)
(0...len).map { [0,1][rand(2)]}.join
end
|
.hi ⇒ Object
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/classbench.rb', line 36
def self.hi
t = Trie.new
100_000.times { t.insert generate_prefix }
puts "Stats"
pp t.get_stats
puts "Done"
end
|
.ip_to_binary_string(ip) ⇒ Object
15
16
17
18
|
# File 'lib/classbench.rb', line 15
def self.ip_to_binary_string(ip)
ip = IP.new(ip)
ip.to_b.to_s[0,ip.pfxlen]
end
|
.load_prefixes_from_file(filename) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/classbench.rb', line 20
def self.load_prefixes_from_file(filename)
t = Trie.new
prefixes = File.readlines(filename).map(&:chomp)
prefixes.each do |pfx|
t.insert ip_to_binary_string(pfx)
end
t
end
|