sfh 1.0.1 → 1.0.2

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.
@@ -1,6 +1,11 @@
1
+ == 0.0.3 / 2008-02-29
2
+ * Fixed issue with native .so version vs RubyInline version
3
+ * The two used a slightly different interface which was lame. Using
4
+ Inline.c_singleton instead of Inline.c now.
5
+
1
6
  == 0.0.2 / 2008-02-29
2
7
  * Updated to use hoe for releases
3
- * Fixed missing dependency (RubyInline)
8
+ * Fixed missing dependency (RubyInline)
4
9
 
5
10
  == 0.0.1 / 2008-02-17
6
11
  * Initial release
@@ -2,7 +2,7 @@ History.txt
2
2
  Manifest.txt
3
3
  README.txt
4
4
  Rakefile
5
- sfh.rb
5
+ lib/sfh.rb
6
6
  bin/sfhsum
7
7
  ext/extconf.rb
8
8
  ext/sfh.c
data/README.txt CHANGED
@@ -10,14 +10,6 @@ This is just a gem for it.
10
10
  * No known issues, let me know if you find any.
11
11
 
12
12
  == SYNOPSIS:
13
- For inline version
14
- require 'sfh'
15
-
16
- h1 = Sfh.new
17
- text1 = "The quick brown fox"
18
- puts "Text '#{text1}': #{h1.hash(text1, text1.length)}"
19
-
20
- The SWIG version is used like this:
21
13
  require 'sfh'
22
14
 
23
15
  text1 = "The quick brown fox"
data/Rakefile CHANGED
@@ -1,13 +1,13 @@
1
1
  require 'rubygems'
2
2
  require 'hoe'
3
- require './sfh.rb'
3
+ require 'lib/sfh.rb'
4
4
 
5
5
  Hoe.new('sfh', Sfh::VERSION) do |p|
6
6
  p.rubyforge_name = 'sfh'
7
7
  p.author = 'Jonathan Wilkins'
8
8
  p.email = 'jwilkins[at]bitland[dot]net'
9
- p.summary = 'SuperFastHash is a hash designed by Paul Hsieh ' +
10
- '(http://www.azillionmonkeys.com/qed/hash.html). ' +
9
+ p.summary = 'SuperFastHash is a hash designed by Paul Hsieh '\
10
+ '(http://www.azillionmonkeys.com/qed/hash.html). '\
11
11
  'This is just a gem for it.'
12
12
  p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
13
13
  p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
@@ -21,7 +21,7 @@ Rake::Task[:test].prerequisites << :extension
21
21
  kind = Config::CONFIG["DLEXT"]
22
22
 
23
23
  desc "Build native version"
24
- task :extension => ["ext/sfh.#{kind}"]
24
+ task :extension => ["ext/sfh_native.#{kind}"]
25
25
 
26
26
  file "ext/Makefile" => "ext/extconf.rb" do
27
27
  Dir.chdir("ext") { ruby "extconf.rb" }
data/bin/sfhsum CHANGED
@@ -3,11 +3,10 @@ require 'rubygems'
3
3
  require 'sfh'
4
4
 
5
5
  if ARGV.size > 0 then
6
- h = Sfh.new
7
6
  ARGV.each do |filename|
8
7
  if FileTest::exists?(filename) then
9
8
  filedata = open(filename).read
10
- puts h.hash(filedata, filedata.length)
9
+ puts Sfh.hash(filedata, filedata.length)
11
10
  else
12
11
  puts "error: can't find '#{filename}'"
13
12
  end
@@ -1,15 +1,15 @@
1
1
  require 'rubygems'
2
2
  require 'inline'
3
3
 
4
- class Sfh
5
- VERSION = '1.0.1'
4
+ module Sfh
5
+ VERSION = '1.0.2'
6
6
 
7
7
  inline(:C) do |builder|
8
8
  builder.include '<stdio.h>'
9
9
  builder.include '<sys/types.h>'
10
10
  builder.include '<stdint.h>'
11
11
 
12
- builder.c '
12
+ builder.c_singleton '
13
13
  unsigned int hash(const char * data, int len)
14
14
  {
15
15
  unsigned int hash = len, tmp;
@@ -60,9 +60,8 @@ class Sfh
60
60
  end
61
61
 
62
62
  if $0 == __FILE__
63
- h = Sfh.new()
64
63
  puts "hashing 'asdf' a million times"
65
64
  1000000.times {
66
- h.hash('asdf', 4)
65
+ Sfh.hash('asdf', 4)
67
66
  }
68
67
  end
@@ -0,0 +1,14 @@
1
+ require '../lib/sfh.rb'
2
+
3
+ str = 'asdf'
4
+ times = 1000000
5
+
6
+ puts "hashing #{str} #{times} times"
7
+ times.times { Sfh.hash(str, str.length) }
8
+ puts "done"
9
+
10
+ times = 1000
11
+ puts "hashing #{str}*1000000 #{times} times"
12
+ str = str*1000000
13
+ times.times { Sfh.hash(str, str.length) }
14
+ puts "done"
@@ -0,0 +1,14 @@
1
+ require '/usr/lib/ruby/gems/1.8/gems/sfh-1.0.2/lib/sfh.so'
2
+
3
+ str = 'asdf'
4
+ times = 1000000
5
+
6
+ puts "hashing #{str} #{times} times"
7
+ times.times { Sfh.hash(str, str.length) }
8
+ puts "done"
9
+
10
+ times = 1000
11
+ puts "hashing #{str}*1000000 #{times} times"
12
+ str = str*1000000
13
+ times.times { Sfh.hash(str, str.length) }
14
+ puts "done"
metadata CHANGED
@@ -3,15 +3,16 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: sfh
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.1
6
+ version: 1.0.2
7
7
  date: 2008-02-29 00:00:00 -08:00
8
- summary: SuperFastHash is a hash designed by Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html). This is just a gem for it.
8
+ summary: SuperFastHash is a hash designed by Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html). This is just a gem for it.
9
9
  require_paths:
10
+ - lib
10
11
  - ext
11
12
  email: jwilkins[at]bitland[dot]net
12
13
  homepage: " by Jonathan Wilkins"
13
14
  rubyforge_project: sfh
14
- description: "== FEATURES/PROBLEMS: * No known issues, let me know if you find any. == SYNOPSIS: For inline version require 'sfh' h1 = Sfh.new text1 = \"The quick brown fox\" puts \"Text '#{text1}': #{h1.hash(text1, text1.length)}\" The SWIG version is used like this: require 'sfh'"
15
+ description: "== FEATURES/PROBLEMS: * No known issues, let me know if you find any. == SYNOPSIS: require 'sfh' text1 = \"The quick brown fox\" puts \"Text '#{text1}': #{Sfh.hash(text1, text1.length)}\" == REQUIREMENTS: RubyInline"
15
16
  autorequire:
16
17
  default_executable:
17
18
  bindir: bin
@@ -33,15 +34,16 @@ files:
33
34
  - Manifest.txt
34
35
  - README.txt
35
36
  - Rakefile
36
- - sfh.rb
37
+ - lib/sfh.rb
37
38
  - bin/sfhsum
38
39
  - ext/extconf.rb
39
40
  - ext/sfh.c
40
41
  - ext/sfh.i
41
42
  - ext/sfh_wrap.c
42
43
  - ext/test_sfh_swig.rb
43
- test_files: []
44
-
44
+ test_files:
45
+ - test/test_sfh_swig.rb
46
+ - test/test_sfh.rb
45
47
  rdoc_options:
46
48
  - --main
47
49
  - README.txt