Skip to content
This repository

Bugfix/subscriber to feed data converter test speed #744

Merged
merged 1 commit into from 11 months ago

2 participants

Dave Wilkinson II Carol Nichols
Dave Wilkinson II
Owner

So. The SubscriberToFeedDataConverter tests won't run on their own. I had to add a bunch of dependencies. I don't really understand why the community shies away from requires in actual files where they depend on things.

Speed

Results related to #706.

Original

$ rake test:file[test/services/subscriber_to_feed_data_converter_test.rb]

6 tests, 1 assertions, 1 failures, 5 errors, 0 skips

Um. Alright. After requiring the dependencies

$ rake test:file[test/services/subscriber_to_feed_data_converter_test.rb]

Finished tests in 0.005167s, 1161.2156 tests/s, 2128.8953 assertions/s.

Well then! Fair enough.

User benchmark

$ time rake test:file[test/services/subscriber_to_feed_data_converter_test.rb]

Finished tests in 0.005005s, 1198.7727 tests/s, 2197.7499 assertions/s.

real    0m7.605s
user    0m7.277s
sys     0m0.303s

rake test:services

$ time rake test:services

Finished tests in 0.258596s, 65.7395 tests/s, 85.0747 assertions/s.

real    0m19.699s
user    0m18.983s
sys     0m0.667s

Overhead of 18-19 seconds.

rake test:services with #743

$ time rake test:services

Finished tests in 0.068574s, 247.9061 tests/s, 320.8196 assertions/s.

real    0m19.544s
user    0m18.800s
sys     0m0.693s

No discernible improvement upon the overhead, which constitutes 28500% of the total user time.

However, this overhead seems to be per file! The file alone was only 7s.

Dave Wilkinson II Fixes the tests so that they can execute on their own.
Speed benchmarks:

```
$ rake
test:file[test/services/subscriber_to_feed_data_converter_test.rb]

6 tests, 1 assertions, 1 failures, 5 errors, 0 skips
```

```
$ rake
test:file[test/services/subscriber_to_feed_data_converter_test.rb]

Finished tests in 0.005167s, 1161.2156 tests/s, 2128.8953 assertions/s.

```

Fair enough.
5752849
Carol Nichols carols10cents merged commit 5752849 into from May 27, 2013
Carol Nichols carols10cents closed this May 27, 2013
Carol Nichols
Owner

:+1: sorry for not merging forever!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 03, 2013
Dave Wilkinson II Fixes the tests so that they can execute on their own.
Speed benchmarks:

```
$ rake
test:file[test/services/subscriber_to_feed_data_converter_test.rb]

6 tests, 1 assertions, 1 failures, 5 errors, 0 skips
```

```
$ rake
test:file[test/services/subscriber_to_feed_data_converter_test.rb]

Finished tests in 0.005167s, 1161.2156 tests/s, 2128.8953 assertions/s.

```

Fair enough.
5752849
This page is out of date. Refresh to see the latest.
95  test/services/subscriber_to_feed_data_converter_test.rb
... ...
@@ -1,6 +1,9 @@
1 1
 require 'minitest/autorun'
2 2
 require 'mocha/setup'
  3
+
3 4
 require 'socket'
  5
+require_relative '../../app/models/feed_data'
  6
+require_relative '../../app/services/finger_service'
4 7
 require_relative '../../app/services/subscriber_to_feed_data_converter'
5 8
 
6 9
 FakeFingerData = Struct.new(:url)
@@ -9,71 +12,73 @@ module RstatUs
9 12
   class InvalidSubscribeTo < StandardError; end
10 13
 end
11 14
 
12  
-describe "converting a subscriber to feed data" do
13  
-  describe "when a Safari 'feed://' scheme is provided" do
14  
-    it "should replace feed:// with http://" do
15  
-      feed_data = SubscriberToFeedDataConverter.new("feed://stuff").get_feed_data!
  15
+describe SubscriberToFeedDataConverter do
  16
+  describe "converting a subscriber to feed data" do
  17
+    describe "when a Safari 'feed://' scheme is provided" do
  18
+      it "should replace feed:// with http://" do
  19
+        feed_data = SubscriberToFeedDataConverter.new("feed://stuff").get_feed_data!
16 20
 
17  
-      assert_equal "http://stuff", feed_data.url
  21
+        assert_equal "http://stuff", feed_data.url
  22
+      end
18 23
     end
19  
-  end
20 24
 
21  
-  describe "when an email address is provided" do
22  
-    it "should finger the user" do
23  
-      email = "somebody@somewhere.com"
  25
+    describe "when an email address is provided" do
  26
+      it "should finger the user" do
  27
+        email = "somebody@somewhere.com"
24 28
 
25  
-      mock_finger_service = mock
26  
-      FingerService.expects(:new).with(email).returns(mock_finger_service)
  29
+        mock_finger_service = mock
  30
+        FingerService.expects(:new).with(email).returns(mock_finger_service)
27 31
 
28  
-      finger_data = FakeFingerData.new("url")
29  
-      mock_finger_service.expects(:finger!).returns(finger_data)
  32
+        finger_data = FakeFingerData.new("url")
  33
+        mock_finger_service.expects(:finger!).returns(finger_data)
30 34
 
31  
-      new_feed_data = SubscriberToFeedDataConverter.new(email).get_feed_data!
  35
+        new_feed_data = SubscriberToFeedDataConverter.new(email).get_feed_data!
32 36
 
33  
-      assert_equal "url", new_feed_data.url
34  
-      assert_equal finger_data, new_feed_data
  37
+        assert_equal "url", new_feed_data.url
  38
+        assert_equal finger_data, new_feed_data
  39
+      end
35 40
     end
36  
-  end
37 41
 
38  
-  describe "when an http:// URL is provided" do
39  
-    it "should use the subscriber URL as the feed URL" do
40  
-      feed_url  = "http://feed.me"
41  
-      feed_data = SubscriberToFeedDataConverter.new(feed_url).get_feed_data!
  42
+    describe "when an http:// URL is provided" do
  43
+      it "should use the subscriber URL as the feed URL" do
  44
+        feed_url  = "http://feed.me"
  45
+        feed_data = SubscriberToFeedDataConverter.new(feed_url).get_feed_data!
42 46
 
43  
-      assert_equal feed_url, feed_data.url
  47
+        assert_equal feed_url, feed_data.url
  48
+      end
44 49
     end
45  
-  end
46 50
 
47  
-  describe "when an https:// URL is provided" do
48  
-    it "should use the subscriber URL as the feed URL" do
49  
-      feed_url  = "https://feed.me"
50  
-      feed_data = SubscriberToFeedDataConverter.new(feed_url).get_feed_data!
  51
+    describe "when an https:// URL is provided" do
  52
+      it "should use the subscriber URL as the feed URL" do
  53
+        feed_url  = "https://feed.me"
  54
+        feed_data = SubscriberToFeedDataConverter.new(feed_url).get_feed_data!
51 55
 
52  
-      assert_equal feed_url, feed_data.url
  56
+        assert_equal feed_url, feed_data.url
  57
+      end
53 58
     end
54  
-  end
55 59
 
56  
-  describe "when we cannot currently understand the subscriber URL" do
57  
-    it "should raise an exception so that we dont try and look it up as a file" do
58  
-      feed_url  = "Gemfile.lock"
  60
+    describe "when we cannot currently understand the subscriber URL" do
  61
+      it "should raise an exception so that we dont try and look it up as a file" do
  62
+        feed_url  = "Gemfile.lock"
59 63
 
60  
-      lambda {
61  
-        SubscriberToFeedDataConverter.new(feed_url).get_feed_data!
62  
-      }.must_raise(RstatUs::InvalidSubscribeTo)
  64
+        lambda {
  65
+          SubscriberToFeedDataConverter.new(feed_url).get_feed_data!
  66
+        }.must_raise(RstatUs::InvalidSubscribeTo)
  67
+      end
63 68
     end
64  
-  end
65 69
 
66  
-  describe "when a network error occurs retrieving the subscriber info" do
67  
-    it "consumes the SocketError and re-raises at an RstatUs exception" do
68  
-      email = "ladygaga@twitter"
  70
+    describe "when a network error occurs retrieving the subscriber info" do
  71
+      it "consumes the SocketError and re-raises at an RstatUs exception" do
  72
+        email = "ladygaga@twitter"
69 73
 
70  
-      mock_finger_service = mock
71  
-      FingerService.expects(:new).with(email).returns(mock_finger_service)
72  
-      mock_finger_service.expects(:finger!).throws(SocketError)
  74
+        mock_finger_service = mock
  75
+        FingerService.expects(:new).with(email).returns(mock_finger_service)
  76
+        mock_finger_service.expects(:finger!).throws(SocketError)
73 77
 
74  
-      lambda {
75  
-        SubscriberToFeedDataConverter.new(email).get_feed_data!
76  
-      }.must_raise(RstatUs::InvalidSubscribeTo)
  78
+        lambda {
  79
+          SubscriberToFeedDataConverter.new(email).get_feed_data!
  80
+        }.must_raise(RstatUs::InvalidSubscribeTo)
  81
+      end
77 82
     end
78 83
   end
79 84
 end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.