win32-nio 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0e0c6f82dd50fb6d6c72e8debf48914350850adb
4
+ data.tar.gz: 375cf9ae2ca2a33313714c3b29180bfb2b391134
5
+ SHA512:
6
+ metadata.gz: ce3a15a046baebf4051e44a62d40f5bd8d13afa7cf2c425ddd9f076a8a92467fc1a77d92a9376f74b59bebff6514e6dc73562ec98a28cab823c0d82ca160566f
7
+ data.tar.gz: 467026cf075920fc853ccdbe6a4eea13418b5b33ab1851e05523dd5010e0b316ab90c24baaafa70323acbd20354cf51074a4564fe155feccc069b64dea78a9c0
data/CHANGES CHANGED
@@ -1,21 +1,27 @@
1
- == 0.1.1 - 10-Apr-2013
2
- * Updated the HANDLE type in the underlying FFI code. This affects
3
- 64 bit versions of Ruby.
4
-
5
- == 0.1.0 - 12-Jul-2012
6
- * Changed from win32-api to FFI.
7
- * Now requires Ruby 1.9 or later.
8
-
9
- == 0.0.3 - 24-Apr-2010
10
- * Removed inline gem building from the gemspec. That's now handled by a
11
- Rakefile task.
12
- * Rafactored the Rakefile, removed an old install task and added new
13
- gem tasks.
14
-
15
- == 0.0.2 - 6-Aug-2009
16
- * License changed to Artistic 2.0.
17
- * Some gemspec updates, including adding win32-event as a dependency and
18
- test-unit as a development dependency.
19
-
20
- == 0.0.1 - 28-Nov-2008
21
- * Initial release
1
+ == 0.1.2 - 20-Oct-2013
2
+ * Fixed the underlying data types for the OVERLAPPED FFI struct. This
3
+ affected 64-bit versions of Ruby.
4
+ * Updated gem:create task for Rubygems 2.x.
5
+ * Removed unnecessary require in test suite.
6
+
7
+ == 0.1.1 - 10-Apr-2013
8
+ * Updated the HANDLE type in the underlying FFI code. This affects
9
+ 64 bit versions of Ruby.
10
+
11
+ == 0.1.0 - 12-Jul-2012
12
+ * Changed from win32-api to FFI.
13
+ * Now requires Ruby 1.9 or later.
14
+
15
+ == 0.0.3 - 24-Apr-2010
16
+ * Removed inline gem building from the gemspec. That's now handled by a
17
+ Rakefile task.
18
+ * Rafactored the Rakefile, removed an old install task and added new
19
+ gem tasks.
20
+
21
+ == 0.0.2 - 6-Aug-2009
22
+ * License changed to Artistic 2.0.
23
+ * Some gemspec updates, including adding win32-event as a dependency and
24
+ test-unit as a development dependency.
25
+
26
+ == 0.0.1 - 28-Nov-2008
27
+ * Initial release
data/MANIFEST CHANGED
@@ -1,13 +1,13 @@
1
- * CHANGES
2
- * MANIFEST
3
- * Rakefile
4
- * README
5
- * win32-nio.gemspec
6
- * benchmarks/win32_nio_benchmarks.rb
7
- * lib/win32/nio.rb
8
- * lib/windows/constants.rb
9
- * lib/windows/functions.rb
10
- * lib/windows/macros.rb
11
- * lib/windows/structs.rb
12
- * test/test_win32_nio_read.rb
13
- * test/test_win32_nio_readlines.rb
1
+ * CHANGES
2
+ * MANIFEST
3
+ * Rakefile
4
+ * README
5
+ * win32-nio.gemspec
6
+ * benchmarks/win32_nio_benchmarks.rb
7
+ * lib/win32/nio.rb
8
+ * lib/windows/constants.rb
9
+ * lib/windows/functions.rb
10
+ * lib/windows/macros.rb
11
+ * lib/windows/structs.rb
12
+ * test/test_win32_nio_read.rb
13
+ * test/test_win32_nio_readlines.rb
data/README CHANGED
@@ -1,72 +1,72 @@
1
- = Description
2
- Native IO for Windows. This class matches and extends the current Ruby
3
- IO class API, using native Windows functions underneath the hood.
4
-
5
- = Installation
6
- gem install win32-nio
7
-
8
- = Synopsis
9
- require 'win32/nio'
10
- include Win32
11
-
12
- p NIO.read('some_file.text')
13
-
14
- p NIO.readlines('some_file.txt')
15
-
16
- = Proof of Concept
17
- This code is ALPHA!
18
-
19
- This code is mostly a proof of concept to see how to implement Ruby's
20
- IO functions in pure Windows functions. While it does offer a couple of
21
- features over and above Ruby's IO interface, such as the ability to supply
22
- an event or a block to the NIO.read method, it offers little practical
23
- advantage at the moment.
24
-
25
- In addition, it is currently using pure Ruby (via FFI), which means
26
- it isn't optimized for speed.
27
-
28
- = Benchmarks
29
-
30
- Using my HP Windows XP Pro laptop, with a 1.66 core duo Pentium T5500 and
31
- 2gb of RAM, I saw these results, which were typical in repeated runs:
32
-
33
- user system total real
34
- IO.read(small) 0.016000 0.047000 0.063000 ( 0.063000)
35
- NIO.read(small) 0.109000 0.000000 0.109000 ( 0.109000)
36
- IO.read(medium) 0.422000 0.094000 0.516000 ( 0.532000)
37
- NIO.read(medium) 0.937000 0.062000 0.999000 ( 1.047000)
38
- IO.read(large) 3.282000 1.063000 4.345000 ( 4.468000)
39
- NIO.read(large) 8.187000 1.062000 9.249000 ( 9.454000)
40
- IO.readlines(small) 0.156000 0.063000 0.219000 ( 0.234000)
41
- NIO.readlines(small) 0.141000 0.000000 0.141000 ( 0.797000)
42
- IO.readlines(medium) 2.984000 0.250000 3.234000 ( 3.625000)
43
- NIO.readlines(medium) 1.172000 0.062000 1.234000 ( 3.406000)
44
- IO.readlines(large) 18.625000 2.281000 20.906000 ( 21.532000)
45
- NIO.readlines(large) 12.406000 0.563000 12.969000 (122.643000)
46
-
47
- Note that, in most cases, the user and system time has decreased, but
48
- the real time has increased.
49
-
50
- = Known Bugs
51
- None that I know of. Please log any other bug reports on the RubyForge
52
- project page at https://github.com/djberg96/win32-nio.
53
-
54
- = Future Plans
55
- The pure Ruby code is really only meant for prototyping. The eventual
56
- plan is to convert the Ruby code to equivalent C code in order to improve
57
- performance.
58
-
59
- = License
60
- Artistic 2.0
61
-
62
- = Copyright
63
- (C) 2008-2013 Daniel J. Berger, All Rights Reserved
64
-
65
- = Warranty
66
- This package is provided "as is" and without any express or
67
- implied warranties, including, without limitation, the implied
68
- warranties of merchantability and fitness for a particular purpose.
69
-
70
- = Author(s)
71
- Daniel Berger
72
- Park Heesob
1
+ = Description
2
+ Native IO for Windows. This class matches and extends the current Ruby
3
+ IO class API, using native Windows functions underneath the hood.
4
+
5
+ = Installation
6
+ gem install win32-nio
7
+
8
+ = Synopsis
9
+ require 'win32/nio'
10
+ include Win32
11
+
12
+ p NIO.read('some_file.text')
13
+
14
+ p NIO.readlines('some_file.txt')
15
+
16
+ = Proof of Concept
17
+ This code is ALPHA!
18
+
19
+ This code is mostly a proof of concept to see how to implement Ruby's
20
+ IO functions in pure Windows functions. While it does offer a couple of
21
+ features over and above Ruby's IO interface, such as the ability to supply
22
+ an event or a block to the NIO.read method, it offers little practical
23
+ advantage at the moment.
24
+
25
+ In addition, it is currently using pure Ruby (via FFI), which means
26
+ it isn't optimized for speed.
27
+
28
+ = Benchmarks
29
+
30
+ Using my HP Windows XP Pro laptop, with a 1.66 core duo Pentium T5500 and
31
+ 2gb of RAM, I saw these results, which were typical in repeated runs:
32
+
33
+ user system total real
34
+ IO.read(small) 0.016000 0.047000 0.063000 ( 0.063000)
35
+ NIO.read(small) 0.109000 0.000000 0.109000 ( 0.109000)
36
+ IO.read(medium) 0.422000 0.094000 0.516000 ( 0.532000)
37
+ NIO.read(medium) 0.937000 0.062000 0.999000 ( 1.047000)
38
+ IO.read(large) 3.282000 1.063000 4.345000 ( 4.468000)
39
+ NIO.read(large) 8.187000 1.062000 9.249000 ( 9.454000)
40
+ IO.readlines(small) 0.156000 0.063000 0.219000 ( 0.234000)
41
+ NIO.readlines(small) 0.141000 0.000000 0.141000 ( 0.797000)
42
+ IO.readlines(medium) 2.984000 0.250000 3.234000 ( 3.625000)
43
+ NIO.readlines(medium) 1.172000 0.062000 1.234000 ( 3.406000)
44
+ IO.readlines(large) 18.625000 2.281000 20.906000 ( 21.532000)
45
+ NIO.readlines(large) 12.406000 0.563000 12.969000 (122.643000)
46
+
47
+ Note that, in most cases, the user and system time has decreased, but
48
+ the real time has increased.
49
+
50
+ = Known Bugs
51
+ None that I know of. Please log any other bug reports on the RubyForge
52
+ project page at https://github.com/djberg96/win32-nio.
53
+
54
+ = Future Plans
55
+ The pure Ruby code is really only meant for prototyping. The eventual
56
+ plan is to convert the Ruby code to equivalent C code in order to improve
57
+ performance.
58
+
59
+ = License
60
+ Artistic 2.0
61
+
62
+ = Copyright
63
+ (C) 2008-2013 Daniel J. Berger, All Rights Reserved
64
+
65
+ = Warranty
66
+ This package is provided "as is" and without any express or
67
+ implied warranties, including, without limitation, the implied
68
+ warranties of merchantability and fitness for a particular purpose.
69
+
70
+ = Author(s)
71
+ Daniel Berger
72
+ Park Heesob
data/Rakefile CHANGED
@@ -1,46 +1,51 @@
1
- require 'rake'
2
- require 'rake/clean'
3
- require 'rake/testtask'
4
-
5
- CLEAN.include("**/*.gem", "**/*.txt")
6
-
7
- namespace 'gem' do
8
- desc 'Create the win32-nio gem'
9
- task :create => [:clean] do
10
- spec = eval(IO.read('win32-nio.gemspec'))
11
- Gem::Builder.new(spec).build
12
- end
13
-
14
- desc 'Install the win32-nio gem'
15
- task :install => [:create] do
16
- file = Dir['*.gem'].first
17
- sh "gem install #{file}"
18
- end
19
- end
20
-
21
- desc 'Run the benchmark suite'
22
- task :bench do
23
- sh "ruby -Ilib benchmarks/win32_nio_benchmarks.rb"
24
- end
25
-
26
- namespace :test do
27
- Rake::TestTask.new(:read) do |t|
28
- t.verbose = true
29
- t.warning = true
30
- t.test_files = FileList['test/test_win32_nio_read.rb']
31
- end
32
-
33
- Rake::TestTask.new(:readlines) do |t|
34
- t.verbose = true
35
- t.warning = true
36
- t.test_files = FileList['test/test_win32_nio_readlines.rb']
37
- end
38
-
39
- Rake::TestTask.new(:all) do |t|
40
- t.verbose = true
41
- t.warning = true
42
- t.test_files = FileList['test/test*.rb']
43
- end
44
- end
45
-
46
- task :default => 'test:all'
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+
5
+ CLEAN.include("**/*.gem", "**/*.txt")
6
+
7
+ namespace 'gem' do
8
+ desc 'Create the win32-nio gem'
9
+ task :create => [:clean] do
10
+ spec = eval(IO.read('win32-nio.gemspec'))
11
+ if Gem::VERSION < "2.0.0"
12
+ Gem::Builder.new(spec).build
13
+ else
14
+ require 'rubygems/package'
15
+ Gem::Package.build(spec)
16
+ end
17
+ end
18
+
19
+ desc 'Install the win32-nio gem'
20
+ task :install => [:create] do
21
+ file = Dir['*.gem'].first
22
+ sh "gem install #{file}"
23
+ end
24
+ end
25
+
26
+ desc 'Run the benchmark suite'
27
+ task :bench do
28
+ sh "ruby -Ilib benchmarks/win32_nio_benchmarks.rb"
29
+ end
30
+
31
+ namespace :test do
32
+ Rake::TestTask.new(:read) do |t|
33
+ t.verbose = true
34
+ t.warning = true
35
+ t.test_files = FileList['test/test_win32_nio_read.rb']
36
+ end
37
+
38
+ Rake::TestTask.new(:readlines) do |t|
39
+ t.verbose = true
40
+ t.warning = true
41
+ t.test_files = FileList['test/test_win32_nio_readlines.rb']
42
+ end
43
+
44
+ Rake::TestTask.new(:all) do |t|
45
+ t.verbose = true
46
+ t.warning = true
47
+ t.test_files = FileList['test/test*.rb']
48
+ end
49
+ end
50
+
51
+ task :default => 'test:all'
@@ -1,113 +1,113 @@
1
- ########################################################################
2
- # win32_nio_benchmarks.rb
3
- #
4
- # Run this via the 'rake bench' task to compare win32-nio with Ruby's
5
- # own IO methods. This benchmark will take a bit of time, since it
6
- # generates some test files on the fly.
7
- ########################################################################
8
- require 'benchmark'
9
- require 'win32/nio'
10
- include Win32
11
-
12
- MAX = (ARGV[0] || '10').chomp.to_i # Default to 10 iterations
13
- PHRASE = "The quick brown fox jumped over the lazy dog's back"
14
-
15
- SMALL_FILE = "small_nio_test.txt" # 588k
16
- MEDIUM_FILE = "medium_nio_test.txt" # 6mb
17
- LARGE_FILE = "large_nio_test.txt" # 60mb
18
- HUGE_FILE = "huge_nio_test.txt" # 618mb
19
-
20
- unless File.exists?(SMALL_FILE)
21
- File.open(SMALL_FILE, 'w'){ |fh|
22
- 10000.times{ |n| fh.puts PHRASE + ": #{n}" }
23
- }
24
-
25
- puts "Small file created"
26
- end
27
-
28
- unless File.exists?(MEDIUM_FILE)
29
- File.open(MEDIUM_FILE, 'w'){ |fh|
30
- 110000.times{ |n| fh.puts PHRASE + ": #{n}" }
31
- }
32
-
33
- puts "Medium file created"
34
- end
35
-
36
- unless File.exists?(LARGE_FILE)
37
- File.open(LARGE_FILE, 'w'){ |fh|
38
- 1000000.times{ |n| fh.puts PHRASE + ": #{n}" }
39
- }
40
-
41
- puts "Large file created"
42
- end
43
-
44
- unless File.exists?(HUGE_FILE)
45
- #File.open(HUGE_FILE, 'w'){ |fh|
46
- # 10000000.times{ |n| fh.puts PHRASE + ": #{n}" }
47
- #}
48
-
49
- #puts "Huge file created"
50
- end
51
-
52
- Benchmark.bm(20) do |x|
53
- x.report('IO.read(small)'){
54
- MAX.times{ IO.read(SMALL_FILE) }
55
- }
56
-
57
- x.report('NIO.read(small)'){
58
- MAX.times{ NIO.read(SMALL_FILE) }
59
- }
60
-
61
- x.report('IO.read(medium)'){
62
- MAX.times{ IO.read(MEDIUM_FILE) }
63
- }
64
-
65
- x.report('NIO.read(medium)'){
66
- MAX.times{ NIO.read(MEDIUM_FILE) }
67
- }
68
-
69
- x.report('IO.read(large)'){
70
- MAX.times{ IO.read(LARGE_FILE) }
71
- }
72
-
73
- x.report('NIO.read(large)'){
74
- MAX.times{ NIO.read(LARGE_FILE) }
75
- }
76
-
77
- #x.report('IO.read(huge)'){
78
- # MAX.times{ IO.read(HUGE_FILE) }
79
- #}
80
-
81
- #x.report('NIO.read(huge)'){
82
- # MAX.times{ NIO.read(HUGE_FILE) }
83
- #}
84
-
85
- x.report('IO.readlines(small)'){
86
- MAX.times{ IO.readlines(SMALL_FILE) }
87
- }
88
-
89
- x.report('NIO.readlines(small)'){
90
- MAX.times{ NIO.readlines(SMALL_FILE) }
91
- }
92
-
93
- x.report('IO.readlines(medium)'){
94
- MAX.times{ IO.readlines(MEDIUM_FILE) }
95
- }
96
-
97
- x.report('NIO.readlines(medium)'){
98
- MAX.times{ NIO.readlines(MEDIUM_FILE) }
99
- }
100
-
101
- x.report('IO.readlines(large)'){
102
- MAX.times{ IO.readlines(LARGE_FILE) }
103
- }
104
-
105
- x.report('NIO.readlines(large)'){
106
- MAX.times{ NIO.readlines(LARGE_FILE) }
107
- }
108
- end
109
-
110
- File.delete(SMALL_FILE) if File.exists?(SMALL_FILE)
111
- File.delete(MEDIUM_FILE) if File.exists?(MEDIUM_FILE)
112
- File.delete(LARGE_FILE) if File.exists?(LARGE_FILE)
113
- File.delete(HUGE_FILE) if File.exists?(HUGE_FILE)
1
+ ########################################################################
2
+ # win32_nio_benchmarks.rb
3
+ #
4
+ # Run this via the 'rake bench' task to compare win32-nio with Ruby's
5
+ # own IO methods. This benchmark will take a bit of time, since it
6
+ # generates some test files on the fly.
7
+ ########################################################################
8
+ require 'benchmark'
9
+ require 'win32/nio'
10
+ include Win32
11
+
12
+ MAX = (ARGV[0] || '10').chomp.to_i # Default to 10 iterations
13
+ PHRASE = "The quick brown fox jumped over the lazy dog's back"
14
+
15
+ SMALL_FILE = "small_nio_test.txt" # 588k
16
+ MEDIUM_FILE = "medium_nio_test.txt" # 6mb
17
+ LARGE_FILE = "large_nio_test.txt" # 60mb
18
+ HUGE_FILE = "huge_nio_test.txt" # 618mb
19
+
20
+ unless File.exists?(SMALL_FILE)
21
+ File.open(SMALL_FILE, 'w'){ |fh|
22
+ 10000.times{ |n| fh.puts PHRASE + ": #{n}" }
23
+ }
24
+
25
+ puts "Small file created"
26
+ end
27
+
28
+ unless File.exists?(MEDIUM_FILE)
29
+ File.open(MEDIUM_FILE, 'w'){ |fh|
30
+ 110000.times{ |n| fh.puts PHRASE + ": #{n}" }
31
+ }
32
+
33
+ puts "Medium file created"
34
+ end
35
+
36
+ unless File.exists?(LARGE_FILE)
37
+ File.open(LARGE_FILE, 'w'){ |fh|
38
+ 1000000.times{ |n| fh.puts PHRASE + ": #{n}" }
39
+ }
40
+
41
+ puts "Large file created"
42
+ end
43
+
44
+ unless File.exists?(HUGE_FILE)
45
+ #File.open(HUGE_FILE, 'w'){ |fh|
46
+ # 10000000.times{ |n| fh.puts PHRASE + ": #{n}" }
47
+ #}
48
+
49
+ #puts "Huge file created"
50
+ end
51
+
52
+ Benchmark.bm(20) do |x|
53
+ x.report('IO.read(small)'){
54
+ MAX.times{ IO.read(SMALL_FILE) }
55
+ }
56
+
57
+ x.report('NIO.read(small)'){
58
+ MAX.times{ NIO.read(SMALL_FILE) }
59
+ }
60
+
61
+ x.report('IO.read(medium)'){
62
+ MAX.times{ IO.read(MEDIUM_FILE) }
63
+ }
64
+
65
+ x.report('NIO.read(medium)'){
66
+ MAX.times{ NIO.read(MEDIUM_FILE) }
67
+ }
68
+
69
+ x.report('IO.read(large)'){
70
+ MAX.times{ IO.read(LARGE_FILE) }
71
+ }
72
+
73
+ x.report('NIO.read(large)'){
74
+ MAX.times{ NIO.read(LARGE_FILE) }
75
+ }
76
+
77
+ #x.report('IO.read(huge)'){
78
+ # MAX.times{ IO.read(HUGE_FILE) }
79
+ #}
80
+
81
+ #x.report('NIO.read(huge)'){
82
+ # MAX.times{ NIO.read(HUGE_FILE) }
83
+ #}
84
+
85
+ x.report('IO.readlines(small)'){
86
+ MAX.times{ IO.readlines(SMALL_FILE) }
87
+ }
88
+
89
+ x.report('NIO.readlines(small)'){
90
+ MAX.times{ NIO.readlines(SMALL_FILE) }
91
+ }
92
+
93
+ x.report('IO.readlines(medium)'){
94
+ MAX.times{ IO.readlines(MEDIUM_FILE) }
95
+ }
96
+
97
+ x.report('NIO.readlines(medium)'){
98
+ MAX.times{ NIO.readlines(MEDIUM_FILE) }
99
+ }
100
+
101
+ x.report('IO.readlines(large)'){
102
+ MAX.times{ IO.readlines(LARGE_FILE) }
103
+ }
104
+
105
+ x.report('NIO.readlines(large)'){
106
+ MAX.times{ NIO.readlines(LARGE_FILE) }
107
+ }
108
+ end
109
+
110
+ File.delete(SMALL_FILE) if File.exists?(SMALL_FILE)
111
+ File.delete(MEDIUM_FILE) if File.exists?(MEDIUM_FILE)
112
+ File.delete(LARGE_FILE) if File.exists?(LARGE_FILE)
113
+ File.delete(HUGE_FILE) if File.exists?(HUGE_FILE)