From 063cbe470ae4d933273df6f1b048e8ac578ccb23 Mon Sep 17 00:00:00 2001 From: Joenio Costa Date: Wed, 15 Jan 2014 11:25:12 -0300 Subject: [PATCH] We need a test that proves the performance improving --- plugins/comment_group/test/unit/article_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+), 0 deletions(-) diff --git a/plugins/comment_group/test/unit/article_test.rb b/plugins/comment_group/test/unit/article_test.rb index 15a963f..4448760 100644 --- a/plugins/comment_group/test/unit/article_test.rb +++ b/plugins/comment_group/test/unit/article_test.rb @@ -1,4 +1,5 @@ require File.dirname(__FILE__) + '/../test_helper' +require 'benchmark' class ArticleTest < ActiveSupport::TestCase @@ -36,4 +37,20 @@ class ArticleTest < ActiveSupport::TestCase assert article.save end + should 'improve performance checking changes in body' do + i = 1 + time0 = (Benchmark.measure { 50.times { + i = i + 1 + article.body = "i = #{i}" + assert article.save + }}) + i = 1 + time1 = (Benchmark.measure { 50.times { + i = i + 1 + article.body = "i = 1" + assert article.save + }}) + assert time0.total > time1.total + end + end -- libgit2 0.21.2