doomfire 0.3.1 → 0.3.2

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: 89b6b146226294362b53ab49479381e4fd58ebba7481ecfd1c8f2106ad8e1714
4
- data.tar.gz: 9141d2f4f5ffcf4be8b4a3447db05a8b08158b916c9914184d3a48a4e26e4b21
3
+ metadata.gz: 50b120f19271148a98f1d664ae43dbbfe315d02f2068a3c141212b83c50a6c54
4
+ data.tar.gz: ca769631b3439bd67deacec8fb3b645b6331752f49bde68864a17533ef196d50
5
5
  SHA512:
6
- metadata.gz: 45a8f024ba820a3aca42ae5a64e6bef4a2cb2388f17a2f7174da05d4aa56cda344dcbea2b802275569969e6110f53097d5a1d3b8fa82d1c41da405812cdcd623
7
- data.tar.gz: 16362cf09982cc961aab53e7034c2f0060a0272539300db4a08f6583635a1030e26d9047cd723033dd13027ad869697bb3f98c675bae5b17eba7d3ff80afacdb
6
+ metadata.gz: '04094f13813531214de2cc074a92c493f75d4be9bb5832dd22a53254de981669eb3723eeb6fc27380aa95107d894707b50660d7e4ec0145af6cbc712b89263a7'
7
+ data.tar.gz: 1a757de3d7a851b9d5f21d04d1df96dcc9b28893ab423b206f5f12b726277479d8f478d4c9d4baa645ef50d141efa8ee0e6876fc4047776fa4553bd0594d2421
@@ -3,8 +3,8 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.3.8
7
- - 2.4.5
8
- - 2.5.5
9
- - 2.6.2
10
- before_install: gem install bundler -v 2.0.1
6
+ - 2.4.9
7
+ - 2.5.7
8
+ - 2.6.5
9
+ - 2.7.0
10
+ before_install: gem install bundler -v 2.1.2
@@ -1,43 +1,45 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- doomfire (0.3.1)
4
+ doomfire (0.3.2)
5
5
  paint
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ benchmark-ips (2.7.2)
10
11
  coderay (1.1.2)
11
12
  diff-lcs (1.3)
12
13
  method_source (0.9.2)
13
- paint (2.1.0)
14
+ paint (2.1.1)
14
15
  pry (0.12.2)
15
16
  coderay (~> 1.1.0)
16
17
  method_source (~> 0.9.0)
17
- rake (10.5.0)
18
- rspec (3.8.0)
19
- rspec-core (~> 3.8.0)
20
- rspec-expectations (~> 3.8.0)
21
- rspec-mocks (~> 3.8.0)
22
- rspec-core (3.8.0)
23
- rspec-support (~> 3.8.0)
24
- rspec-expectations (3.8.3)
18
+ rake (13.0.1)
19
+ rspec (3.9.0)
20
+ rspec-core (~> 3.9.0)
21
+ rspec-expectations (~> 3.9.0)
22
+ rspec-mocks (~> 3.9.0)
23
+ rspec-core (3.9.1)
24
+ rspec-support (~> 3.9.1)
25
+ rspec-expectations (3.9.0)
25
26
  diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.8.0)
27
- rspec-mocks (3.8.0)
27
+ rspec-support (~> 3.9.0)
28
+ rspec-mocks (3.9.0)
28
29
  diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.8.0)
30
- rspec-support (3.8.0)
30
+ rspec-support (~> 3.9.0)
31
+ rspec-support (3.9.2)
31
32
 
32
33
  PLATFORMS
33
34
  ruby
34
35
 
35
36
  DEPENDENCIES
36
- bundler (~> 2.0)
37
+ benchmark-ips
38
+ bundler
37
39
  doomfire!
38
40
  pry
39
- rake (~> 10.0)
40
- rspec (~> 3.0)
41
+ rake
42
+ rspec
41
43
 
42
44
  BUNDLED WITH
43
- 2.0.1
45
+ 2.1.2
data/README.md CHANGED
@@ -69,6 +69,15 @@ Then you can run the executable:
69
69
 
70
70
  And the output should be shown in a separate window. Closing the window will end the program after a few seconds of the ending animation.
71
71
 
72
+ ![SDL example](examples/sdl.png)
73
+
74
+ If running on a Ruby interpreter on the JVM, you will need the `-XstartOnFirstThread` option.
75
+
76
+ ## Benchmarks
77
+
78
+ $ bundle exec bench/micro.rb
79
+ $ bundle exec bench/macro.rb
80
+
72
81
  ## Contributing
73
82
 
74
83
  Bug reports and pull requests are welcome on GitHub at https://github.com/marcinruszkiewicz/doomfire.
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'doomfire'
4
+ require 'doomfire/ffi_sdl'
5
+ require 'doomfire/sdl'
6
+
7
+ # Benchmark of the whole of Doomfire running in SDL mode. Prints FPS to
8
+ # the screen every second. Manually observe the warmup curve before taking
9
+ # a reading.
10
+
11
+ puts 'Wait for FPS to stabilise before taking a reading...'
12
+
13
+ class Bench < Doomfire::SDL
14
+
15
+ def print_pixels
16
+ super
17
+ record_frame
18
+ end
19
+
20
+ def record_frame
21
+ time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
22
+
23
+ if @start.nil?
24
+ @start = time
25
+ @frames = 0
26
+ end
27
+
28
+ @frames += 1
29
+ elapsed = time - @start
30
+
31
+ if elapsed > 1
32
+ printf "%.2f fps\n", @frames / elapsed
33
+ @start = time
34
+ @frames = 0
35
+ end
36
+ end
37
+
38
+ end
39
+
40
+ Bench.new.run
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'fiddle'
4
+ require 'fiddle/import'
5
+
6
+ require 'doomfire'
7
+ require 'doomfire/ffi_sdl'
8
+ require 'doomfire/sdl'
9
+
10
+ require 'benchmark/ips'
11
+
12
+ class BaseBench < Doomfire::Base
13
+
14
+ public :spread_fire, :update_pixels
15
+
16
+ def prepare_output
17
+ @fire_width = 80
18
+ @fire_height = 35
19
+ end
20
+
21
+ def bench_spread_fire
22
+ spread_fire(14 * @fire_width + 16)
23
+ end
24
+
25
+ end
26
+
27
+ base_bench = BaseBench.new
28
+
29
+ module LibM
30
+ extend Fiddle::Importer
31
+ dlload 'libSystem.B.dylib'
32
+ extern 'double floor(double)'
33
+ end
34
+
35
+ string = 'x' * 80 * 35
36
+
37
+ class SDLBench < Doomfire::SDL
38
+
39
+ def initialize
40
+ super
41
+ @texdata = texdata
42
+ end
43
+
44
+ def prepare_output
45
+ @fire_width = 80
46
+ @fire_height = 35
47
+ end
48
+
49
+ def texdata
50
+ @pixels.map { |val| ARGB[val] }
51
+ end
52
+
53
+ def texptr
54
+ Fiddle::Pointer[@texdata.pack('L*')]
55
+ end
56
+
57
+ end
58
+
59
+ sdl_bench = SDLBench.new
60
+
61
+ Benchmark.ips do |x|
62
+
63
+ x.iterations = 3
64
+
65
+ x.report('spread_fire') do
66
+ base_bench.bench_spread_fire
67
+ end
68
+
69
+ x.report('update_pixels') do
70
+ base_bench.update_pixels
71
+ end
72
+
73
+ x.report('call') do
74
+ LibM.floor(14.2)
75
+ end
76
+
77
+ x.report('pointer') do
78
+ Fiddle::Pointer[string]
79
+ end
80
+
81
+ x.report('texdata') do
82
+ sdl_bench.texdata
83
+ end
84
+
85
+ x.report('texptr') do
86
+ sdl_bench.texptr
87
+ end
88
+
89
+ end
@@ -24,8 +24,9 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_dependency 'paint'
26
26
 
27
- spec.add_development_dependency 'bundler', '~> 2.0'
27
+ spec.add_development_dependency 'benchmark-ips'
28
+ spec.add_development_dependency 'bundler'
28
29
  spec.add_development_dependency 'pry'
29
- spec.add_development_dependency 'rake', '~> 10.0'
30
- spec.add_development_dependency 'rspec', '~> 3.0'
30
+ spec.add_development_dependency 'rake'
31
+ spec.add_development_dependency 'rspec'
31
32
  end
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Doomfire
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doomfire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Ruszkiewicz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-31 00:00:00.000000000 Z
11
+ date: 2019-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paint
@@ -24,20 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '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: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '2.0'
47
+ version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: '2.0'
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: pry
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -56,30 +70,30 @@ dependencies:
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: '10.0'
75
+ version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: '10.0'
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rspec
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "~>"
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
- version: '3.0'
89
+ version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
- version: '3.0'
96
+ version: '0'
83
97
  description: Puts your console on fire. Use a truecolor console for best effect.
84
98
  email:
85
99
  - marcin.ruszkiewicz@polcode.net
@@ -97,8 +111,11 @@ files:
97
111
  - LICENSE.txt
98
112
  - README.md
99
113
  - Rakefile
114
+ - bench/macro.rb
115
+ - bench/micro.rb
100
116
  - doomfire.gemspec
101
117
  - examples/long.rake
118
+ - examples/sdl.png
102
119
  - examples/terminal.png
103
120
  - exe/doomfire
104
121
  - lib/doomfire.rb