LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
List overview
Download
Projects
----- 2025 -----
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
projects@lrde.epita.fr
1049 discussions
Start a n
N
ew thread
Re: [ranch] 37: Factorize project request in a filter.
by Akim Demaille
>>> "Nicolas" == Nicolas Desprès <nicolas.despres(a)lrde.epita.fr> writes: > Factorize project request in a filter. Factor, bon sang.
19 years, 1 month
2
1
0
0
[ranch] 39: Move the revision field from benches to outputs.
by Nicolas Despr�s
https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog from Nicolas Desprès <nicolas.despres(a)lrde.epita.fr> Move the revision field from benches to outputs. * web/ranch/db/schema.rb: Move the revision field from the benches table to the outputs table. * web/ranch/test/unit/bench_test.rb, * web/ranch/test/unit/output_test.rb, * web/ranch/test/fixtures/outputs.yml, * web/ranch/test/fixtures/benches.yml, * web/ranch/app/models/bench.rb, * web/ranch/app/models/output.rb: Update. app/models/bench.rb | 11 +---------- app/models/output.rb | 6 +++++- db/schema.rb | 9 ++------- test/fixtures/benches.yml | 4 ---- test/fixtures/outputs.yml | 1 + test/unit/bench_test.rb | 5 ----- test/unit/output_test.rb | 5 +++++ 7 files changed, 14 insertions(+), 27 deletions(-) Index: web/ranch/test/unit/bench_test.rb --- web/ranch/test/unit/bench_test.rb (revision 38) +++ web/ranch/test/unit/bench_test.rb (working copy) @@ -12,11 +12,6 @@ assert !bench.save end - def test_save_presence_of_revision - bench = Bench.new(:name => 'foo', :revision => 0) - assert !bench.save - end - def test_save_maximum_lenght_of_name bench = Bench.new(:name => '' * 256) assert !bench.save Index: web/ranch/test/unit/output_test.rb --- web/ranch/test/unit/output_test.rb (revision 38) +++ web/ranch/test/unit/output_test.rb (working copy) @@ -17,4 +17,9 @@ assert !output.save end + def test_save_presence_of_revision + output = Output.new(:name => 'foo', :revision => 0) + assert !output.save + end + end Index: web/ranch/test/fixtures/outputs.yml --- web/ranch/test/fixtures/outputs.yml (revision 38) +++ web/ranch/test/fixtures/outputs.yml (working copy) @@ -22,6 +22,7 @@ arg_num: <%= arg_num += 1 %> set_num: <%= set_num %> system_id: 0 + revision: <%= rev %> <% end %> <% set_num += 1 Index: web/ranch/test/fixtures/benches.yml --- web/ranch/test/fixtures/benches.yml (revision 38) +++ web/ranch/test/fixtures/benches.yml (working copy) @@ -5,24 +5,20 @@ id: <%= id += 1 %> project_id: 1 name: determinize - revision: <%= rev %> <% end %> quotient: id: <%= id += 1 %> project_id: 1 name: quotient - revision: 1 open: id: <%= id += 1 %> project_id: 2 name: open - revision: 1 close: id: <%= id += 1 %> project_id: 2 name: close - revision: 1 Index: web/ranch/app/models/bench.rb --- web/ranch/app/models/bench.rb (revision 38) +++ web/ranch/app/models/bench.rb (working copy) @@ -3,16 +3,7 @@ belongs_to :project has_many :output - validates_presence_of :name, :revision - validates_numericality_of :revision, :only_integer => true + validates_presence_of :name validates_length_of :name, :maximum => 255 - protected - - def validate - unless revision.to_i > 0 - errors.add("revision", "is not positive") - end - end - end Index: web/ranch/app/models/output.rb --- web/ranch/app/models/output.rb (revision 38) +++ web/ranch/app/models/output.rb (working copy) @@ -3,9 +3,10 @@ belongs_to :bench belongs_to :system - validates_presence_of :name, :value, :arg_num, :set_num + validates_presence_of :name, :value, :arg_num, :set_num, :revision validates_numericality_of :value validates_numericality_of :arg_num, :set_num, :only_integer => true + validates_numericality_of :revision, :only_integer => true validates_length_of :name, :unit, :maximum => 128 protected @@ -13,6 +14,9 @@ def validate errors.add("arg_num", "is not positive") unless arg_num.to_i >= 0 errors.add("set_num", "is not positive") unless set_num.to_i >= 0 + unless revision.to_i > 0 + errors.add("revision", "is not positive") + end end end Index: web/ranch/db/schema.rb --- web/ranch/db/schema.rb (revision 38) +++ web/ranch/db/schema.rb (working copy) @@ -5,9 +5,8 @@ ActiveRecord::Schema.define() do create_table "benches", :force => true do |t| - t.column "name", :string, :limit => 255, :default => "noname", :null => false + t.column "name", :string, :default => "noname", :null => false t.column "project_id", :integer, :default => 1, :null => false - t.column "revision", :integer, :default => 1, :null => false end add_index "benches", ["project_id"], :name => "project_id" @@ -29,6 +28,7 @@ t.column "arg_num", :integer, :limit => 8, :default => 1, :null => false t.column "set_num", :integer, :default => 0, :null => false t.column "system_id", :integer, :default => 1, :null => false + t.column "revision", :integer, :default => 1, :null => false end add_index "outputs", ["bench_id"], :name => "bench_id" @@ -40,11 +40,6 @@ create_table "systems", :force => true do |t| t.column "hostname", :string, :limit => 128, :default => "localhost", :null => false - t.column "info", :text, :default => "", :null => false - end - - create_table "systems", :force => true do |t| - t.column "hostname", :string, :limit => 128, :default => "localhost", :null => false t.column "kernel_name", :string, :limit => 64 t.column "kernel_version", :string, :limit => 64 t.column "host_type", :string, :limit => 64
19 years, 1 month
1
0
0
0
[ranch] 38: Clean condition usage.
by Nicolas Despr�s
https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog from Nicolas Desprès <nicolas.despres(a)lrde.epita.fr> Clean condition usage. * web/ranch/app/models/project.rb: Use Rails syntax instead of ugly plain string. project.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: web/ranch/app/models/project.rb --- web/ranch/app/models/project.rb (revision 37) +++ web/ranch/app/models/project.rb (working copy) @@ -8,7 +8,7 @@ validates_length_of :name, :maximum => 255 def bench_ordered_by_name - Bench.find :all, :conditions => "project_id = #{id}", :order => "name" + Bench.find :all, :conditions => [ "project_id = ?", id ], :order => "name" end protected
19 years, 1 month
1
0
0
0
[ranch] 37: Factorize project request in a filter.
by Nicolas Despr�s
https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog from Nicolas Desprès <nicolas.despres(a)lrde.epita.fr> Factorize project request in a filter. * web/ranch/app/controllers/ranch_controller.rb, * web/ranch/app/controllers/projects_controller.rb, * web/ranch/app/controllers/graph_form_controller.rb: Use the LoadProjectFilter. * web/ranch/app/filters/load_projects_filter.rb: New. Request the project list. * web/ranch/app/views/layouts/_left_margin.rhtml: Use a project attribute instead of a session key. * web/ranch/app/models/project.rb: Query associated benches and sort them. * web/ranch/config/environment.rb: Lazyly preload the filters files. app/controllers/graph_form_controller.rb | 3 +++ app/controllers/projects_controller.rb | 2 ++ app/controllers/ranch_controller.rb | 2 ++ app/filters/load_projects_filter.rb | 9 +++++++++ app/models/project.rb | 4 ++++ app/views/layouts/_left_margin.rhtml | 23 ++++++----------------- config/environment.rb | 5 +++++ 7 files changed, 31 insertions(+), 17 deletions(-) Index: web/ranch/app/models/project.rb --- web/ranch/app/models/project.rb (revision 36) +++ web/ranch/app/models/project.rb (working copy) @@ -7,6 +7,10 @@ validates_numericality_of :head_revision, :only_integer => true validates_length_of :name, :maximum => 255 + def bench_ordered_by_name + Bench.find :all, :conditions => "project_id = #{id}", :order => "name" + end + protected def validate Index: web/ranch/app/controllers/ranch_controller.rb --- web/ranch/app/controllers/ranch_controller.rb (revision 36) +++ web/ranch/app/controllers/ranch_controller.rb (working copy) @@ -2,6 +2,8 @@ layout 'ranch_benches_list' + before_filter LoadProjectsFilter + def index end Index: web/ranch/app/filters/load_projects_filter.rb --- web/ranch/app/filters/load_projects_filter.rb (revision 0) +++ web/ranch/app/filters/load_projects_filter.rb (revision 0) @@ -0,0 +1,9 @@ +class LoadProjectsFilter + + def self.filter(controller) + controller.instance_eval do + @projects = Project.find :all, :order => "name" + end + end + +end Index: web/ranch/app/views/layouts/_left_margin.rhtml --- web/ranch/app/views/layouts/_left_margin.rhtml (revision 36) +++ web/ranch/app/views/layouts/_left_margin.rhtml (working copy) @@ -1,19 +1,9 @@ <!-- -*- html -*- --> -<% - if session[:projects].nil? or session[:benches].nil? - session[:projects] = Project.find_by_sql "SELECT id, name " + - "FROM projects " + - "WHERE 1 " + - "ORDER BY name" - session[:benches] = Bench.find_by_sql "SELECT id, name, project_id " + - "FROM benches " + - "WHERE 1 " + - "GROUP BY name " + - "ORDER BY project_id, name" - end -%> <table> - <% for project in session[:projects] %> + <% if @projects.nil? or @projects.empty? %> + no projects available + <% else %> + <% for project in @projects %> <tr> <td><%= link_to project.name, :controller => "projects", :action => "show", @@ -22,8 +12,7 @@ <tr> <td> <table> - <% for bench in session[:benches] %> - <% if bench.project_id == project.id %> + <% for bench in project.bench_ordered_by_name %> <tr> <td width=10> </td> @@ -35,7 +24,7 @@ </td> </tr> <% end %> - <% end %> </table> <% end %> + <% end %> </table> Index: web/ranch/config/environment.rb --- web/ranch/config/environment.rb (revision 36) +++ web/ranch/config/environment.rb (working copy) @@ -52,3 +52,8 @@ require 'grapher' require 'tempfile' +# Preload filters lazyly. +Pathname.glob("#{RAILS_ROOT}/app/filters/*_filter.rb") do |pathname| + autoload(pathname.basename.to_s.sub(/\.rb$/, '').classify.to_sym, + pathname.to_s) +end Index: web/ranch/app/controllers/projects_controller.rb --- web/ranch/app/controllers/projects_controller.rb (revision 36) +++ web/ranch/app/controllers/projects_controller.rb (working copy) @@ -2,6 +2,8 @@ layout 'ranch_benches_list' + before_filter LoadProjectsFilter + def show @project = Project.find_by_id params[:project_id] end Index: web/ranch/app/controllers/graph_form_controller.rb --- web/ranch/app/controllers/graph_form_controller.rb (revision 36) +++ web/ranch/app/controllers/graph_form_controller.rb (working copy) @@ -1,8 +1,11 @@ class GraphFormController < ApplicationController + helper :graph, :graph_form layout 'ranch_benches_list' + before_filter LoadProjectsFilter + DEFAULT_REVISION_RANGE = 100 def index
19 years, 1 month
1
0
0
0
[ranch] 36: System validates rules.
by Nicolas Despr�s
https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog from Nicolas Desprès <nicolas.despres(a)lrde.epita.fr> System validates rules. * web/ranch/app/models/system.rb: Add system fields validates rules. system.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) Index: web/ranch/app/models/system.rb --- web/ranch/app/models/system.rb (revision 35) +++ web/ranch/app/models/system.rb (working copy) @@ -2,7 +2,15 @@ has_many :output - validates_presence_of :hostname, :info + validates_presence_of :hostname validates_length_of :hostname, :maximum => 128 + validates_length_of :kernel_name, :maximum => 128 + validates_length_of :kernel_version, :maximum => 128 + validates_length_of :host_type, :maximum => 128 + validates_length_of :os_name, :maximum => 128 + validates_length_of :os_version, :maximum => 128 + validates_length_of :comp_name, :maximum => 128 + validates_length_of :comp_version, :maximum => 128 + validates_length_of :comp_flags, :maximum => 128 end
19 years, 1 month
1
0
0
0
[ranch] 35: Add more fields to the systems table.
by Nicolas Despr�s
https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog from Nicolas Desprès <nicolas.despres(a)lrde.epita.fr> Add more fields to the systems table. * web/ranch/db/schema.rb: Add more fields to the systems table. * web/ranch/test/fixtures/systems.yml: Update accordingly. db/schema.rb | 17 +++++++++++++++-- test/fixtures/systems.yml | 8 ++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) Index: web/ranch/db/schema.rb --- web/ranch/db/schema.rb (revision 34) +++ web/ranch/db/schema.rb (working copy) @@ -5,7 +5,7 @@ ActiveRecord::Schema.define() do create_table "benches", :force => true do |t| - t.column "name", :string, :default => "noname", :null => false + t.column "name", :string, :limit => 255, :default => "noname", :null => false t.column "project_id", :integer, :default => 1, :null => false t.column "revision", :integer, :default => 1, :null => false end @@ -34,7 +34,7 @@ add_index "outputs", ["bench_id"], :name => "bench_id" create_table "projects", :force => true do |t| - t.column "name", :string, :default => "noname", :null => false + t.column "name", :string, :limit => 128, :default => "noname", :null => false t.column "head_revision", :integer, :default => 1, :null => false end @@ -43,4 +43,17 @@ t.column "info", :text, :default => "", :null => false end + create_table "systems", :force => true do |t| + t.column "hostname", :string, :limit => 128, :default => "localhost", :null => false + t.column "kernel_name", :string, :limit => 64 + t.column "kernel_version", :string, :limit => 64 + t.column "host_type", :string, :limit => 64 + t.column "os_name", :string, :limit => 64 + t.column "os_version", :string, :limit => 64 + t.column "comp_name", :string, :limit => 64 + t.column "comp_version", :string, :limit => 64 + t.column "comp_flags", :string, :limit => 64 + t.column "info", :text + end + end Index: web/ranch/test/fixtures/systems.yml --- web/ranch/test/fixtures/systems.yml (revision 34) +++ web/ranch/test/fixtures/systems.yml (working copy) @@ -1,6 +1,14 @@ ouagadougou: id: 1 hostname: ouagadougou.lrde.epita.fr + kernel_name: Linux + kernel_version: "2.4.27-2-k7 #1 Tue Aug 16 17:30:14" + host_type: i686 + os_name: GNU/Linux + os_version: + comp_name: g++ + comp_version: 4.0.3 + comp_flags: -02 -W -Wall info: | Running action system SYSTEM UNAME: CYGWIN_NT-5.1 pau 1.5.18(0.132/4/2) 2005-07-02 20:30 i686 unknown unknown Cygwin
19 years, 1 month
1
0
0
0
[ranch] 34: Add scores after stop.
by Nicolas Despr�s
https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog from Nicolas Despr�s <nicolas.despres(a)gmail.com> Add scores after stop. * lib/cxx/test/bencher-test.htt: Test it. * lib/cxx/src/ranch-cxx/outputs.hh, * lib/cxx/src/ranch-cxx/outputs.hxx: Add size accessor. * lib/cxx/src/ranch-cxx/output/output.hxx, * lib/cxx/src/ranch-cxx/output/output.hh, * lib/cxx/src/ranch-cxx/output/output.cc: Ensure that multiple call to start/stop perform the real start/stop only once. Use start_/stop_ internally. * lib/cxx/src/ranch-cxx/output/u-time.cc, * lib/cxx/src/ranch-cxx/output/u-time.hh: Overload start_/stop_. * lib/cxx/src/ranch-cxx/bencher.cc, * lib/cxx/src/ranch-cxx/bencher.hh: Add the add_score methods that allow to add the result once the benchmark is stopped. src/ranch-cxx/bencher.cc | 43 ++++++++++++++++++++++++++++++- src/ranch-cxx/bencher.hh | 14 ++++++++++ src/ranch-cxx/output/output.cc | 4 +- src/ranch-cxx/output/output.hh | 10 +++++-- src/ranch-cxx/output/output.hxx | 21 ++++++++++++++- src/ranch-cxx/output/u-time.cc | 4 +- src/ranch-cxx/output/u-time.hh | 7 ++--- src/ranch-cxx/outputs.hh | 4 ++ src/ranch-cxx/outputs.hxx | 5 +++ test/bencher-test.htt | 54 ++++++++++++++++++++++++++++++++++++++++ 10 files changed, 153 insertions(+), 13 deletions(-) Index: lib/cxx/test/bencher-test.htt --- lib/cxx/test/bencher-test.htt (revision 33) +++ lib/cxx/test/bencher-test.htt (working copy) @@ -81,6 +81,60 @@ TS_ASSERT_EQUALS(oss.str(), out); } + void test_one_add_score_after_stop_with_specified_output() + { + std::ostringstream oss; + Ranch::Dumper::Yaml dumper(oss); + Ranch::Bencher::dumper(dumper); + + Ranch::Input::Input foo("foo", "unit_foo"); + Ranch::Input::Input bar("bar", "unit_bar"); + + Ranch::Output::Output toto("toto", "unit_toto"); + Ranch::Output::Output tata("tata", "unit_tata"); + + Ranch::Bencher b("test1", "a comment"); + b.add_input(foo); + b.add_input(bar); + b.add_output(toto).add_output(tata); + + b.start(1.0, 2.0); + std::string out = OUTPUT_CTOR_1; + out += OUTPUT_START_1; + TS_ASSERT_EQUALS(oss.str(), out); + b.stop(); + b.add_score(tata, 22.0).add_score(toto, 11.0); + out += OUTPUT_STOP_1; + TS_ASSERT_EQUALS(oss.str(), out); + } + + void test_one_add_score_after_stop_without_specified_output() + { + std::ostringstream oss; + Ranch::Dumper::Yaml dumper(oss); + Ranch::Bencher::dumper(dumper); + + Ranch::Input::Input foo("foo", "unit_foo"); + Ranch::Input::Input bar("bar", "unit_bar"); + + Ranch::Output::Output toto("toto", "unit_toto"); + Ranch::Output::Output tata("tata", "unit_tata"); + + Ranch::Bencher b("test1", "a comment"); + b.add_input(foo); + b.add_input(bar); + b.add_output(toto).add_output(tata); + + b.start(1.0, 2.0); + std::string out = OUTPUT_CTOR_1; + out += OUTPUT_START_1; + TS_ASSERT_EQUALS(oss.str(), out); + b.stop(); + b.add_score(11.0).add_score(22.0); + out += OUTPUT_STOP_1; + TS_ASSERT_EQUALS(oss.str(), out); + } + void test_several() { std::ostringstream oss; Index: lib/cxx/src/ranch-cxx/outputs.hh --- lib/cxx/src/ranch-cxx/outputs.hh (revision 33) +++ lib/cxx/src/ranch-cxx/outputs.hh (working copy) @@ -25,6 +25,10 @@ iterator begin(); iterator end(); + typedef list_type::size_type size_type; + + size_type size() const; + protected: list_type list_; }; // class Outputs Index: lib/cxx/src/ranch-cxx/outputs.hxx --- lib/cxx/src/ranch-cxx/outputs.hxx (revision 33) +++ lib/cxx/src/ranch-cxx/outputs.hxx (working copy) @@ -33,6 +33,11 @@ return list_.end(); } + inline Outputs::size_type Outputs::size() const + { + return list_.size(); + } + } // namespace Ranch #endif // !RANCH_OUTPUTS_HXX Index: lib/cxx/src/ranch-cxx/bencher.cc --- lib/cxx/src/ranch-cxx/bencher.cc (revision 33) +++ lib/cxx/src/ranch-cxx/bencher.cc (working copy) @@ -28,7 +28,9 @@ inputs_(inputs), outputs_(outputs), comment_(comment), - first_start_call_(true) + first_start_call_(true), + score_set_num_(0), + cur_output_(NULL) { } @@ -37,7 +39,9 @@ inputs_(), outputs_(), comment_(comment), - first_start_call_(true) + first_start_call_(true), + score_set_num_(0), + cur_output_(NULL) { } @@ -73,6 +77,8 @@ { va_list ap; + stop_outputs_(); + Outputs::iterator i = outputs_.begin(); (*i)->value(score_output_1); @@ -83,6 +89,29 @@ dumper_->end_score(*this); } + void Bencher::stop() + { + stop_outputs_(); + } + + Bencher& Bencher::add_score(Output::Output& output, double score) + { + output.value(score); + ++score_set_num_; + if (score_set_num_ >= outputs_.size()) + dumper_->end_score(*this); + return *this; + } + + Bencher& Bencher::add_score(double score) + { + (*cur_output_)->value(score); + ++cur_output_; + if (cur_output_ == outputs_.end()) + dumper_->end_score(*this); + return *this; + } + void Bencher::start_outputs_() { for (Outputs::iterator i = outputs_.begin(); @@ -91,8 +120,18 @@ (*i)->start(); } + void Bencher::stop_outputs_() + { + for (Outputs::iterator i = outputs_.begin(); + i != outputs_.end(); + ++i) + (*i)->stop(); + } + void Bencher::begin_bench_() { + score_set_num_ = 0; + cur_output_ = outputs_.begin(); if (first_start_call_) { first_start_call_ = false; Index: lib/cxx/src/ranch-cxx/output/output.cc --- lib/cxx/src/ranch-cxx/output/output.cc (revision 33) +++ lib/cxx/src/ranch-cxx/output/output.cc (working copy) @@ -9,11 +9,11 @@ { } - void Output::start() + void Output::start_() { } - void Output::stop() + void Output::stop_() { } Index: lib/cxx/src/ranch-cxx/output/u-time.cc --- lib/cxx/src/ranch-cxx/output/u-time.cc (revision 33) +++ lib/cxx/src/ranch-cxx/output/u-time.cc (working copy) @@ -9,12 +9,12 @@ namespace Output { - void UTime::start() + void UTime::start_() { start_time_ = utime_(); } - void UTime::stop() + void UTime::stop_() { value_ = (utime_() - start_time_) * sysconf(_SC_CLK_TCK) * 1.0e-4; } Index: lib/cxx/src/ranch-cxx/output/output.hxx --- lib/cxx/src/ranch-cxx/output/output.hxx (revision 33) +++ lib/cxx/src/ranch-cxx/output/output.hxx (working copy) @@ -11,7 +11,8 @@ { inline Output::Output(const std::string& name, const std::string& unit) : - IO(name, unit) + IO(name, unit), + started_(false) { } @@ -21,6 +22,24 @@ return value_; } + inline void Output::start() + { + if (!started_) + { + start_(); + started_ = true; + } + } + + inline void Output::stop() + { + if (started_) + { + stop_(); + started_ = false; + } + } + } // namespace Output } // namespace Ranch Index: lib/cxx/src/ranch-cxx/output/output.hh --- lib/cxx/src/ranch-cxx/output/output.hh (revision 33) +++ lib/cxx/src/ranch-cxx/output/output.hh (working copy) @@ -18,11 +18,17 @@ Output(const std::string& name, const std::string& unit = ""); virtual ~Output(); - virtual void start(); - virtual void stop(); + void start(); + void stop(); double operator() (); + protected: + virtual void start_(); + virtual void stop_(); + + bool started_; + }; // class Output } // namespace Output Index: lib/cxx/src/ranch-cxx/output/u-time.hh --- lib/cxx/src/ranch-cxx/output/u-time.hh (revision 33) +++ lib/cxx/src/ranch-cxx/output/u-time.hh (working copy) @@ -15,13 +15,12 @@ public: UTime(); - virtual void start(); - virtual void stop(); - protected: + virtual void start_(); + virtual void stop_(); + double utime_(); - protected: double start_time_; }; // class UTime Index: lib/cxx/src/ranch-cxx/bencher.hh --- lib/cxx/src/ranch-cxx/bencher.hh (revision 33) +++ lib/cxx/src/ranch-cxx/bencher.hh (working copy) @@ -37,10 +37,18 @@ void start(double size_input_1, ...); // There is always at least one output. void stop(double score_output_1, ...); + void stop(); Bencher& add_input(Input::Input& input); Bencher& add_output(Output::Output& output); + // Add a score according to the specified output. Do not mix with + // add_score(double). + Bencher& add_score(Output::Output& output, double score); + // Add a score in order of declaration. Do not mix with + // add_score(Output::Output&, double). + Bencher& add_score(double score); + const std::string& name() const; const Inputs& inputs() const; const Outputs& outputs() const; @@ -48,6 +56,7 @@ protected: void start_outputs_(); + void stop_outputs_(); void begin_bench_(); protected: @@ -55,7 +64,12 @@ Inputs inputs_; Outputs outputs_; std::string comment_; + // Necessary since we may use add_input/add_output. bool first_start_call_; + // Necessary to dump the score once every excepted score are registered. + unsigned score_set_num_; + // Necessary to manage add_score(double). + Outputs::iterator cur_output_; }; // class Bencher
19 years, 1 month
1
0
0
0
vcs-cvs co: -z3
by Akim Demaille
~/src % cvs -z3 -d akim@savannah.gnu.org:/cvsroot/texinfo co texinfo [vcs] error: invalid option: -z3 ~/src % \cvs -z3 -d akim@savannah.gnu.org:/cvsroot/texinfo co texinfo cvs server: Updating texinfo U texinfo/.cvsignore U texinfo/ABOUT-NLS
19 years, 1 month
1
0
0
0
[ranch] 33: Add record field validation.
by Nicolas Despr�s
https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog from Nicolas Despr�s <nicolas.despres(a)gmail.com> Add record field validation. * web/ranch/test/unit/bench_test.rb, * web/ranch/test/unit/input_test.rb, * web/ranch/test/unit/output_test.rb, * web/ranch/test/unit/system_test.rb, * web/ranch/test/unit/project_test.rb: Test record field validation. * web/ranch/test/fixtures/outputs.yml, * web/ranch/test/fixtures/benches.yml, * web/ranch/test/fixtures/systems.yml, * web/ranch/test/fixtures/projects.yml: Update fixtures according to changes in the db schema. * web/ranch/app/models/bench.rb, * web/ranch/app/models/input.rb, * web/ranch/app/models/output.rb, * web/ranch/app/models/system.rb, * web/ranch/app/models/project.rb: Implement record field validation. * web/ranch/db/schema.rb: Add the system table and the relation ship with the other tables. app/models/bench.rb | 13 ++++++++++++- app/models/input.rb | 12 ++++++++++++ app/models/output.rb | 13 +++++++++++++ app/models/project.rb | 13 +++++++++++++ app/models/system.rb | 5 ++++- db/schema.rb | 18 +++++++++--------- test/fixtures/benches.yml | 1 - test/fixtures/outputs.yml | 1 + test/fixtures/projects.yml | 7 ++++--- test/fixtures/systems.yml | 35 +++++++++++++++++++++++++++++++---- test/unit/bench_test.rb | 21 ++++++++++++++++++--- test/unit/input_test.rb | 16 +++++++++++++--- test/unit/output_test.rb | 16 +++++++++++++--- test/unit/project_test.rb | 42 +++++++++++++++++++++++++++++++++++++++--- test/unit/system_test.rb | 2 -- 15 files changed, 182 insertions(+), 33 deletions(-) Index: web/ranch/test/unit/bench_test.rb --- web/ranch/test/unit/bench_test.rb (revision 32) +++ web/ranch/test/unit/bench_test.rb (working copy) @@ -3,8 +3,23 @@ class BenchTest < Test::Unit::TestCase fixtures :benches - # Replace this with your real tests. - def test_truth - assert_kind_of Bench, benches(:first) + def test_save_default + assert Bench.new.save end + + def test_save_presence_of_name + bench = Bench.new(:name => '') + assert !bench.save + end + + def test_save_presence_of_revision + bench = Bench.new(:name => 'foo', :revision => 0) + assert !bench.save + end + + def test_save_maximum_lenght_of_name + bench = Bench.new(:name => '' * 256) + assert !bench.save + end + end Index: web/ranch/test/unit/input_test.rb --- web/ranch/test/unit/input_test.rb (revision 32) +++ web/ranch/test/unit/input_test.rb (working copy) @@ -3,8 +3,18 @@ class InputTest < Test::Unit::TestCase fixtures :inputs - # Replace this with your real tests. - def test_truth - assert_kind_of Input, inputs(:first) + def test_save_default + assert Input.new.save end + + def test_save_arg_num_is_positive + output = Output.new(:arg_num => -1) + assert !output.save + end + + def test_save_set_num_is_positive_or_zero + output = Output.new(:set_num => -1) + assert !output.save + end + end Index: web/ranch/test/unit/output_test.rb --- web/ranch/test/unit/output_test.rb (revision 32) +++ web/ranch/test/unit/output_test.rb (working copy) @@ -3,8 +3,18 @@ class OutputTest < Test::Unit::TestCase fixtures :outputs - # Replace this with your real tests. - def test_truth - assert_kind_of Output, outputs(:first) + def test_save_default + assert Output.new.save end + + def test_save_arg_num_is_positive + output = Output.new(:arg_num => -1) + assert !output.save + end + + def test_save_set_num_is_positive_or_zero + output = Output.new(:set_num => -1) + assert !output.save + end + end Index: web/ranch/test/unit/system_test.rb --- web/ranch/test/unit/system_test.rb (revision 32) +++ web/ranch/test/unit/system_test.rb (working copy) @@ -3,8 +3,6 @@ class SystemTest < Test::Unit::TestCase fixtures :systems - # Replace this with your real tests. def test_truth - assert_kind_of System, systems(:first) end end Index: web/ranch/test/unit/project_test.rb --- web/ranch/test/unit/project_test.rb (revision 32) +++ web/ranch/test/unit/project_test.rb (working copy) @@ -3,8 +3,44 @@ class ProjectTest < Test::Unit::TestCase fixtures :projects - # Replace this with your real tests. - def test_truth - assert_kind_of Project, projects(:first) + def test_save_default + assert Project.new.save end + + def test_save_bad_head_revision_not_numeric + foo = Project.new(:name => 'foo', :head_revision => 'foo') + assert ! foo.save + assert_equal 2, foo.errors.count + assert_raises(ActiveRecord::RecordNotFound) { Project.find(foo.id) } + end + + def test_save_bad_head_revision_not_positive + foo = Project.new(:name => 'foo', :head_revision => -50) + assert ! foo.save + assert_equal 1, foo.errors.count + assert_raises(ActiveRecord::RecordNotFound) { Project.find(foo.id) } + end + + def test_save_empty_project_name + foo = Project.new(:name => '', :head_revision => 50) + assert ! foo.save + assert_equal 1, foo.errors.count + assert_raises(ActiveRecord::RecordNotFound) { Project.find(foo.id) } + end + + def test_save_name_uniqness + foo = Project.new(:name => 'foo', :head_revision => 50) + assert foo.save + foo = Project.new(:name => 'foo', :head_revision => 50) + assert ! foo.save + end + + def test_save_ok + foo = Project.new(:name => 'foo', :head_revision => 50) + assert foo.save + project = Project.find foo.id + assert_equal 'foo', foo.name + assert_equal 50, foo.head_revision + end + end Index: web/ranch/test/fixtures/outputs.yml --- web/ranch/test/fixtures/outputs.yml (revision 32) +++ web/ranch/test/fixtures/outputs.yml (working copy) @@ -21,6 +21,7 @@ bench_id: <%= rev %> arg_num: <%= arg_num += 1 %> set_num: <%= set_num %> + system_id: 0 <% end %> <% set_num += 1 Index: web/ranch/test/fixtures/benches.yml --- web/ranch/test/fixtures/benches.yml (revision 32) +++ web/ranch/test/fixtures/benches.yml (working copy) @@ -1,4 +1,3 @@ -# Read about fixtures at
http://ar.rubyonrails.org/classes/Fixtures.html
<% id = 0 %> <% (1..10).each do |rev| %> Index: web/ranch/test/fixtures/systems.yml --- web/ranch/test/fixtures/systems.yml (revision 32) +++ web/ranch/test/fixtures/systems.yml (working copy) @@ -1,5 +1,32 @@ -# Read about fixtures at
http://ar.rubyonrails.org/classes/Fixtures.html
-first: +ouagadougou: id: 1 -another: - id: 2 + hostname: ouagadougou.lrde.epita.fr + info: | + Running action system + SYSTEM UNAME: CYGWIN_NT-5.1 pau 1.5.18(0.132/4/2) 2005-07-02 20:30 i686 unknown unknown Cygwin + BUILD DATE: Mon Nov 14 10:13:51 2005 + BUILD SHORTDATE: 14/11 10:13 + HIGHEST SVN REVISION: 26 + BUILD REVISION: 6 + PKG_CONFIG_PATH: + PATH: /cygdrive/d/build_farm/prefix/monoburg/bin:/usr/local/bin:/bin:/cygdrive/c/ghc/ghc-6.4/bin:/cygdrive/c/program files/imagemagick-6.2.5-q16:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Program Files/Intel/DMIX:/bin + BF_DEPS: + + CFLAGS: + CXXFLAGS: + CC: ccache gcc + CXX: ccache g++ + CONFIGURE OPTIONS: --prefix=/cygdrive/d/build_farm/prefix/ranch + DISTCHECK_CONFIGURE_FLAGS: + + --- gcc (/bin/gcc) --- + gcc (GCC) 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125) + Copyright (C) 2004 Free Software Foundation, Inc. + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + --- g++ (/bin/g++) --- + g++ (GCC) 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125) + Copyright (C) 2004 Free Software Foundation, Inc. + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Index: web/ranch/test/fixtures/projects.yml --- web/ranch/test/fixtures/projects.yml (revision 32) +++ web/ranch/test/fixtures/projects.yml (working copy) @@ -1,11 +1,12 @@ -# Read about fixtures at
http://ar.rubyonrails.org/classes/Fixtures.html
+<% id = 0 %> + vaucanson: - id: 1 + id: <%= id += 1 %> name: Vaucanson head_revision: 10 olena: - id: 2 + id: <%= id += 1 %> name: Olena head_revision: 100 Index: web/ranch/app/models/bench.rb --- web/ranch/app/models/bench.rb (revision 32) +++ web/ranch/app/models/bench.rb (working copy) @@ -2,6 +2,17 @@ belongs_to :project has_many :output - belongs_to :system + + validates_presence_of :name, :revision + validates_numericality_of :revision, :only_integer => true + validates_length_of :name, :maximum => 255 + + protected + + def validate + unless revision.to_i > 0 + errors.add("revision", "is not positive") + end + end end Index: web/ranch/app/models/input.rb --- web/ranch/app/models/input.rb (revision 32) +++ web/ranch/app/models/input.rb (working copy) @@ -2,4 +2,16 @@ belongs_to :bench + validates_presence_of :name, :value, :arg_num, :set_num + validates_numericality_of :value + validates_numericality_of :arg_num, :set_num, :only_integer => true + validates_length_of :name, :unit, :maximum => 128 + + protected + + def validate + errors.add("arg_num", "is not positive") unless arg_num.to_i >= 0 + errors.add("set_num", "is not positive") unless set_num.to_i >= 0 + end + end Index: web/ranch/app/models/output.rb --- web/ranch/app/models/output.rb (revision 32) +++ web/ranch/app/models/output.rb (working copy) @@ -1,5 +1,18 @@ class Output < ActiveRecord::Base belongs_to :bench + belongs_to :system + + validates_presence_of :name, :value, :arg_num, :set_num + validates_numericality_of :value + validates_numericality_of :arg_num, :set_num, :only_integer => true + validates_length_of :name, :unit, :maximum => 128 + + protected + + def validate + errors.add("arg_num", "is not positive") unless arg_num.to_i >= 0 + errors.add("set_num", "is not positive") unless set_num.to_i >= 0 + end end Index: web/ranch/app/models/system.rb --- web/ranch/app/models/system.rb (revision 32) +++ web/ranch/app/models/system.rb (working copy) @@ -1,5 +1,8 @@ class System < ActiveRecord::Base - has_many :bench + has_many :output + + validates_presence_of :hostname, :info + validates_length_of :hostname, :maximum => 128 end Index: web/ranch/app/models/project.rb --- web/ranch/app/models/project.rb (revision 32) +++ web/ranch/app/models/project.rb (working copy) @@ -2,4 +2,17 @@ has_many :bench + validates_presence_of :name + validates_uniqueness_of :name + validates_numericality_of :head_revision, :only_integer => true + validates_length_of :name, :maximum => 255 + + protected + + def validate + unless head_revision.to_i > 0 + errors.add("head_revision", "is not positive") + end + end + end Index: web/ranch/db/schema.rb --- web/ranch/db/schema.rb (revision 32) +++ web/ranch/db/schema.rb (working copy) @@ -5,19 +5,18 @@ ActiveRecord::Schema.define() do create_table "benches", :force => true do |t| - t.column "name", :string, :limit => 128, :default => "noname", :null => false - t.column "project_id", :integer, :default => 0, :null => false - t.column "revision", :integer, :default => 0, :null => false - t.column "system_id", :integer, :default => 0, :null => false + t.column "name", :string, :default => "noname", :null => false + t.column "project_id", :integer, :default => 1, :null => false + t.column "revision", :integer, :default => 1, :null => false end add_index "benches", ["project_id"], :name => "project_id" create_table "inputs", :force => true do |t| t.column "name", :string, :limit => 128, :default => "noname", :null => false - t.column "unit", :string, :limit => 128, :default => "nounit", :null => false + t.column "unit", :string, :limit => 128, :default => "", :null => false t.column "value", :float, :default => 0.0, :null => false - t.column "bench_id", :integer, :default => 0, :null => false + t.column "bench_id", :integer, :default => 1, :null => false t.column "arg_num", :integer, :limit => 8, :default => 1, :null => false t.column "set_num", :integer, :default => 0, :null => false end @@ -25,17 +24,18 @@ create_table "outputs", :force => true do |t| t.column "name", :string, :limit => 128, :default => "noname", :null => false t.column "value", :float, :default => 0.0, :null => false - t.column "unit", :string, :limit => 128, :default => "nounit", :null => false - t.column "bench_id", :integer, :default => 0, :null => false + t.column "unit", :string, :limit => 128, :default => "", :null => false + t.column "bench_id", :integer, :default => 1, :null => false t.column "arg_num", :integer, :limit => 8, :default => 1, :null => false t.column "set_num", :integer, :default => 0, :null => false + t.column "system_id", :integer, :default => 1, :null => false end add_index "outputs", ["bench_id"], :name => "bench_id" create_table "projects", :force => true do |t| t.column "name", :string, :default => "noname", :null => false - t.column "head_revision", :integer, :default => 0, :null => false + t.column "head_revision", :integer, :default => 1, :null => false end create_table "systems", :force => true do |t|
19 years, 1 month
1
0
0
0
[ranch] 32: Add the systems table.
by Nicolas Despr�s
https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog from Nicolas Despr�s <nicolas.despres(a)gmail.com> Add the systems table. * web/ranch/test/unit/system_test.rb: New. Test unit of the model. * web/ranch/test/fixtures/systems.yml: New. Fixtures for the model. * web/ranch/app/models/system.rb: New. Models corresponding to the table. * web/ranch/app/models/bench.rb: Benches table has a system_id field. * web/ranch/db/schema.rb: Add the system table. app/models/bench.rb | 1 + app/models/system.rb | 5 +++++ db/schema.rb | 6 ++++++ test/fixtures/systems.yml | 5 +++++ test/unit/system_test.rb | 10 ++++++++++ 5 files changed, 27 insertions(+) Index: web/ranch/test/unit/system_test.rb --- web/ranch/test/unit/system_test.rb (revision 0) +++ web/ranch/test/unit/system_test.rb (revision 0) @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class SystemTest < Test::Unit::TestCase + fixtures :systems + + # Replace this with your real tests. + def test_truth + assert_kind_of System, systems(:first) + end +end Index: web/ranch/test/fixtures/systems.yml --- web/ranch/test/fixtures/systems.yml (revision 0) +++ web/ranch/test/fixtures/systems.yml (revision 0) @@ -0,0 +1,5 @@ +# Read about fixtures at
http://ar.rubyonrails.org/classes/Fixtures.html
+first: + id: 1 +another: + id: 2 Index: web/ranch/app/models/bench.rb --- web/ranch/app/models/bench.rb (revision 31) +++ web/ranch/app/models/bench.rb (working copy) @@ -2,5 +2,6 @@ belongs_to :project has_many :output + belongs_to :system end Index: web/ranch/app/models/system.rb --- web/ranch/app/models/system.rb (revision 0) +++ web/ranch/app/models/system.rb (revision 0) @@ -0,0 +1,5 @@ +class System < ActiveRecord::Base + + has_many :bench + +end Index: web/ranch/db/schema.rb --- web/ranch/db/schema.rb (revision 31) +++ web/ranch/db/schema.rb (working copy) @@ -8,6 +8,7 @@ t.column "name", :string, :limit => 128, :default => "noname", :null => false t.column "project_id", :integer, :default => 0, :null => false t.column "revision", :integer, :default => 0, :null => false + t.column "system_id", :integer, :default => 0, :null => false end add_index "benches", ["project_id"], :name => "project_id" @@ -37,4 +38,9 @@ t.column "head_revision", :integer, :default => 0, :null => false end + create_table "systems", :force => true do |t| + t.column "hostname", :string, :limit => 128, :default => "localhost", :null => false + t.column "info", :text, :default => "", :null => false + end + end
19 years, 1 month
1
0
0
0
← Newer
1
...
72
73
74
75
76
77
78
...
105
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
Results per page:
10
25
50
100
200