grntest 1.7.4 → 1.7.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec1bd62dfcf7d618511ed7c0883b8e32326b1b7eee388c71202d93dd5232c0c4
4
- data.tar.gz: 95fe9cec3b9289980bb6954b99f47351dc012c45a5bf28e16ab1c2633aadb4f1
3
+ metadata.gz: b9cd8b74ac4dd886a08f1550309a467d95b39f1adc182a915ace5bb10f7c0f78
4
+ data.tar.gz: ba6b74681a3a7523d0d48ed298efffb4d4d0fede4c0869401fba949e617f02b4
5
5
  SHA512:
6
- metadata.gz: d4e76e424c2bde8a576b2913964f37cdf0a1f7d96b81cd4c2c2e015033886b890e8729cc9d7c4339742ee35e1be500736a68bd4c9b3254730200ff75d05dae0f
7
- data.tar.gz: 6815b9a5489bf74f2fa1ed0f3b73bdffbdf518b567fc2a1fc2e25786bd5eddd2dfdc2ce6c649f6b1a864db9d6e1b574578a446a84265ab90fbecdf70b4cf676e
6
+ metadata.gz: d285a5183996b4390e93dac09e5416fd8f3e5decbadf4b8ed95458534e65cdd1d74b11efa6635d79e3687de7c7a09a83c1c2d2c6471b0455dfead94061158fdb
7
+ data.tar.gz: 2fbba81eeb21ebdfdebbcd51d758ad836b54f5017fb27b404025c4d0a930bbf686a71f397e73a0cb66de16c7d84e6231dc3662fc4cd907d201908281f0811494
data/doc/text/news.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # News
2
2
 
3
+ ## 1.7.5: 2024-04-12
4
+
5
+ ### Improvements
6
+
7
+ * `#@generate-series`: Improved performance.
8
+
9
+ * `#@require-env`: Added to run tests only when the given
10
+ environment variable is defined.
11
+
3
12
  ## 1.7.4: 2024-04-05
4
13
 
5
14
  ### Improvements
@@ -308,28 +308,43 @@ module Grntest
308
308
  @context.collect_query_log = (options[0] == "true")
309
309
  end
310
310
 
311
+ def each_generated_series_chunk(evaluator, start, stop)
312
+ max_chunk_size = 1 * 1024 * 1024 # 1MiB
313
+ chunk_size = 0
314
+ records = []
315
+ (Integer(start)..Integer(stop)).each do |i|
316
+ record = evaluator.evaluate(i: i).to_json
317
+ records << record
318
+ chunk_size += record.bytesize
319
+ if chunk_size > max_chunk_size
320
+ yield(records)
321
+ records.clear
322
+ chunk_size = 0
323
+ end
324
+ end
325
+ yield(records) unless records.empty?
326
+ end
327
+
311
328
  def execute_directive_generate_series(parser, line, content, options)
312
329
  start, stop, table, template, = options
313
330
  evaluator = TemplateEvaluator.new(template.force_encoding("UTF-8"))
314
- (Integer(start)..Integer(stop)).each_slice(1000) do |range|
315
- parser << "load --table #{table}\n"
316
- parser << "["
317
- first_record = true
318
- range.each do |i|
319
- record = ""
320
- if first_record
321
- first_record = false
322
- else
323
- record << ","
324
- end
325
- record << "\n"
326
- record << evaluator.evaluate(i: i).to_json
327
- before = Time.now
328
- parser << record
329
- elapsed = Time.now - before
330
- Thread.pass if elapsed > 1.0
331
+ each_generated_series_chunk(evaluator,
332
+ Integer(start),
333
+ Integer(stop)) do |records|
334
+ source = "load --table #{table}\n"
335
+ values_part_start_position = source.size
336
+ source << "["
337
+ records.each_with_index do |record, i|
338
+ source << "," unless i.zero?
339
+ source << "\n"
340
+ source << record
331
341
  end
332
- parser << "\n]\n"
342
+ source << "\n]"
343
+ values = source[values_part_start_position..-1]
344
+ command = Groonga::Command::Load.new(table: table, values: values)
345
+ command.original_source = source
346
+ execute_command(command)
347
+ Thread.pass
333
348
  end
334
349
  end
335
350
 
@@ -534,6 +549,19 @@ module Grntest
534
549
  @benchmark_result = @noop_benchmark_result
535
550
  end
536
551
 
552
+ def execute_directive_require_env(line, content, options)
553
+ env, = options
554
+ if env.start_with?("!")
555
+ if ENV[env[1..-1]]
556
+ omit("require env: #{env}")
557
+ end
558
+ else
559
+ unless ENV[env]
560
+ omit("require env: #{env}")
561
+ end
562
+ end
563
+ end
564
+
537
565
  def execute_directive(parser, line, content)
538
566
  command, *options = Shellwords.split(content)
539
567
  case command
@@ -597,6 +625,8 @@ module Grntest
597
625
  execute_directive_start_benchmark(line, content, options)
598
626
  when "finish-benchmark"
599
627
  execute_directive_finish_benchmark(line, content, options)
628
+ when "require-env"
629
+ execute_directive_require_env(line, content, options)
600
630
  else
601
631
  log_input(line)
602
632
  log_error("#|e| unknown directive: <#{command}>")
@@ -14,5 +14,5 @@
14
14
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
15
 
16
16
  module Grntest
17
- VERSION = "1.7.4"
17
+ VERSION = "1.7.5"
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grntest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.4
4
+ version: 1.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  - Haruka Yoshihara
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-05 00:00:00.000000000 Z
11
+ date: 2024-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs