serialbench 0.8.0 → 0.8.1
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 +4 -4
- data/lib/serialbench/version.rb +1 -1
- data/lib/serialbench.rb +0 -1
- metadata +1 -3
- data/lib/serialbench/config_manager.rb +0 -129
- data/lib/serialbench/memory_profiler.rb +0 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 55b58686ee445c84cbbf69588022d932a56c7014255567c19d3bc44c2ddbad53
|
|
4
|
+
data.tar.gz: 0353b87e4e5d5690a706e2ef3b2e3d96f85166092b098893c13b9024b56acf4e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fdf9e8086fa5e7960151717340df5f131679af2389bf4126801f9a2ab777fed04f3eba511d108e2a4fe2d3f9e47c723970a22911b20880a162d93fdf85f7ace5
|
|
7
|
+
data.tar.gz: 665f581b8491ce518a0602f76dfc7227ae51c14f343bbf650c6ee5e4b735b3d64676d4af3fd2b6e10d9eb16209ca9ec412763072183d1101cf6e63c40088a83d
|
data/lib/serialbench/version.rb
CHANGED
data/lib/serialbench.rb
CHANGED
|
@@ -4,7 +4,6 @@ require_relative 'serialbench/version'
|
|
|
4
4
|
require_relative 'serialbench/serializers'
|
|
5
5
|
require_relative 'serialbench/benchmark_runner'
|
|
6
6
|
require_relative 'serialbench/cli'
|
|
7
|
-
require_relative 'serialbench/memory_profiler'
|
|
8
7
|
require_relative 'serialbench/models'
|
|
9
8
|
|
|
10
9
|
module Serialbench
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: serialbench
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose
|
|
@@ -305,8 +305,6 @@ files:
|
|
|
305
305
|
- lib/serialbench/cli/environment_cli.rb
|
|
306
306
|
- lib/serialbench/cli/ruby_build_cli.rb
|
|
307
307
|
- lib/serialbench/cli/validate_cli.rb
|
|
308
|
-
- lib/serialbench/config_manager.rb
|
|
309
|
-
- lib/serialbench/memory_profiler.rb
|
|
310
308
|
- lib/serialbench/models.rb
|
|
311
309
|
- lib/serialbench/models/benchmark_config.rb
|
|
312
310
|
- lib/serialbench/models/benchmark_result.rb
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'yaml'
|
|
4
|
-
require 'ostruct'
|
|
5
|
-
require_relative 'schema_validator'
|
|
6
|
-
|
|
7
|
-
module Serialbench
|
|
8
|
-
# Manages configuration loading and validation for Serialbench
|
|
9
|
-
class ConfigManager
|
|
10
|
-
class ConfigurationError < StandardError; end
|
|
11
|
-
|
|
12
|
-
SCHEMA_PATH = File.join(__dir__, '../../docs/serialbench_config_schema.yaml')
|
|
13
|
-
|
|
14
|
-
# Load and validate configuration from file
|
|
15
|
-
def self.load_and_validate(config_path)
|
|
16
|
-
new.load_and_validate(config_path)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def initialize
|
|
20
|
-
@validator = SchemaValidator.new
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Load configuration file and validate against schema
|
|
24
|
-
def load_and_validate(config_path)
|
|
25
|
-
raise ConfigurationError, "Configuration file not found: #{config_path}" unless File.exist?(config_path)
|
|
26
|
-
|
|
27
|
-
begin
|
|
28
|
-
config_data = YAML.load_file(config_path)
|
|
29
|
-
rescue Psych::SyntaxError => e
|
|
30
|
-
raise ConfigurationError, "Invalid YAML syntax in #{config_path}: #{e.message}"
|
|
31
|
-
rescue StandardError => e
|
|
32
|
-
raise ConfigurationError, "Error reading configuration file #{config_path}: #{e.message}"
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
validate_config(config_data, config_path)
|
|
36
|
-
normalize_config(config_data)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
private
|
|
40
|
-
|
|
41
|
-
# Validate configuration against schema
|
|
42
|
-
def validate_config(config_data, _config_path)
|
|
43
|
-
# For now, perform basic validation since we don't have a specific config schema validator
|
|
44
|
-
validate_basic_config(config_data)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Load the configuration schema
|
|
48
|
-
def load_schema
|
|
49
|
-
raise ConfigurationError, "Configuration schema not found: #{SCHEMA_PATH}" unless File.exist?(SCHEMA_PATH)
|
|
50
|
-
|
|
51
|
-
begin
|
|
52
|
-
YAML.load_file(SCHEMA_PATH)
|
|
53
|
-
rescue StandardError => e
|
|
54
|
-
raise ConfigurationError, "Error loading configuration schema: #{e.message}"
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# Normalize and convert configuration to structured object
|
|
59
|
-
def normalize_config(config_data)
|
|
60
|
-
config = OpenStruct.new(config_data)
|
|
61
|
-
|
|
62
|
-
# Apply defaults
|
|
63
|
-
config.output_dir ||= 'benchmark-results'
|
|
64
|
-
config.benchmark_config ||= 'config/full.yml'
|
|
65
|
-
config.auto_install = true if config.auto_install.nil?
|
|
66
|
-
|
|
67
|
-
# Validate runtime-specific requirements
|
|
68
|
-
case config.runtime
|
|
69
|
-
when 'docker'
|
|
70
|
-
validate_docker_config(config)
|
|
71
|
-
when 'asdf'
|
|
72
|
-
validate_asdf_config(config)
|
|
73
|
-
else
|
|
74
|
-
raise ConfigurationError, "Unknown runtime: #{config.runtime}"
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
config
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
# Validate Docker-specific configuration
|
|
81
|
-
def validate_docker_config(config)
|
|
82
|
-
raise ConfigurationError, "Docker runtime requires 'image_variants' to be specified" unless config.image_variants && !config.image_variants.empty?
|
|
83
|
-
|
|
84
|
-
invalid_variants = config.image_variants - %w[slim alpine]
|
|
85
|
-
return if invalid_variants.empty?
|
|
86
|
-
|
|
87
|
-
raise ConfigurationError, "Invalid image variants: #{invalid_variants.join(', ')}. Valid variants: slim, alpine"
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# Validate ASDF-specific configuration
|
|
91
|
-
def validate_asdf_config(config)
|
|
92
|
-
# Check if ASDF is available
|
|
93
|
-
raise ConfigurationError, 'ASDF is not installed or not in PATH. Please install ASDF to use asdf runtime.' unless command_available?('asdf')
|
|
94
|
-
|
|
95
|
-
# Validate Ruby version format for ASDF (should include patch version)
|
|
96
|
-
config.ruby_versions.each do |version|
|
|
97
|
-
raise ConfigurationError, "ASDF runtime requires full version numbers (e.g., '3.2.8'), got: #{version}" unless version.match?(/^\d+\.\d+\.\d+$/)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# Basic configuration validation
|
|
102
|
-
def validate_basic_config(config_data)
|
|
103
|
-
# Check required fields
|
|
104
|
-
required_fields = %w[runtime ruby_versions output_dir benchmark_config]
|
|
105
|
-
required_fields.each do |field|
|
|
106
|
-
raise ConfigurationError, "Missing required field: #{field}" unless config_data.key?(field)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
# Validate runtime
|
|
110
|
-
valid_runtimes = %w[docker asdf]
|
|
111
|
-
unless valid_runtimes.include?(config_data['runtime'])
|
|
112
|
-
raise ConfigurationError,
|
|
113
|
-
"Invalid runtime: #{config_data['runtime']}. Valid runtimes: #{valid_runtimes.join(', ')}"
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
# Validate ruby_versions is an array
|
|
117
|
-
raise ConfigurationError, 'ruby_versions must be an array' unless config_data['ruby_versions'].is_a?(Array)
|
|
118
|
-
|
|
119
|
-
return unless config_data['ruby_versions'].empty?
|
|
120
|
-
|
|
121
|
-
raise ConfigurationError, 'ruby_versions cannot be empty'
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
# Check if a command is available in PATH
|
|
125
|
-
def command_available?(command)
|
|
126
|
-
system("which #{command} > /dev/null 2>&1")
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Serialbench
|
|
4
|
-
class MemoryProfiler
|
|
5
|
-
def self.profile(&block)
|
|
6
|
-
return yield unless defined?(::MemoryProfiler)
|
|
7
|
-
|
|
8
|
-
::MemoryProfiler.report(&block)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def self.available?
|
|
12
|
-
require 'memory_profiler'
|
|
13
|
-
defined?(::MemoryProfiler) ? true : false
|
|
14
|
-
rescue LoadError
|
|
15
|
-
false
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def self.format_report(report)
|
|
19
|
-
return 'Memory profiling not available' unless report
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
total_allocated: report.total_allocated,
|
|
23
|
-
total_retained: report.total_retained,
|
|
24
|
-
allocated_memory: report.total_allocated_memsize,
|
|
25
|
-
retained_memory: report.total_retained_memsize,
|
|
26
|
-
allocated_objects_by_gem: report.allocated_memory_by_gem,
|
|
27
|
-
retained_objects_by_gem: report.retained_memory_by_gem
|
|
28
|
-
}
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|