Pardon, je l'ai envoyé à la main pensant que la procédure automatique n'avait pas foncionné, mais en fait elle a juste pris beaucoup de temps...
On 11/18/06, Nicolas Desprès nicolas.despres@gmail.com wrote:
https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog from Nicolas Desprès nicolas.despres@gmail.com
Add a Time Stamp Counter measure. * lib/cxx/demo/basic.cc: Rename to ... * lib/cxx/demo/utime.cc: ... that and remove dead code. * lib/cxx/demo/Makefile.am: Add the tsc demo. * lib/cxx/demo/tsc.cc: New. A demo for the TSC measure. * lib/cxx/src/ranch-cxx/output/Makefile.am: Add the tsc files. * lib/cxx/src/ranch-cxx/output/all.hh: Include the TSC header. * lib/cxx/src/ranch-cxx/output/tsc.hxx, * lib/cxx/src/ranch-cxx/output/tsc.hh, * lib/cxx/src/ranch-cxx/output/tsc.cc: New. Implements the TSC measure. * lib/cxx/src/ranch-cxx/bencher.hh: Typo.
demo/Makefile.am | 16 +++++++++++----- demo/tsc.cc | 30 ++++++++++++++++++++++++++++++ demo/utime.cc | 6 ------ src/ranch-cxx/bencher.hh | 2 +- src/ranch-cxx/output/Makefile.am | 9 +++++++-- src/ranch-cxx/output/all.hh | 1 + src/ranch-cxx/output/tsc.cc | 28 ++++++++++++++++++++++++++++ src/ranch-cxx/output/tsc.hh | 32 ++++++++++++++++++++++++++++++++ src/ranch-cxx/output/tsc.hxx | 20 ++++++++++++++++++++ 9 files changed, 130 insertions(+), 14 deletions(-)
Index: lib/cxx/demo/utime.cc --- lib/cxx/demo/utime.cc (revision 70) +++ lib/cxx/demo/utime.cc (working copy) @@ -12,12 +12,6 @@ return i; }
-void basic(const double foo, const double bar, double& toto, double& tata) -{
- toto = foo + bar;
- tata = foo * bar;
-}
int main() { Ranch::Input::Input foo("foo", "unit_foo"); Index: lib/cxx/demo/Makefile.am --- lib/cxx/demo/Makefile.am (revision 70) +++ lib/cxx/demo/Makefile.am (working copy) @@ -1,7 +1,13 @@ include $(top_srcdir)/src/ranch.mk
-check_PROGRAMS = basic -basic_SOURCES = basic.cc -basic_CXXFLAGS = -W -Wall -pedantic -O3 -basic_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src -basic_LDADD = $(top_builddir)/src/ranch-cxx/libranch-cxx.la +check_PROGRAMS = utime tsc
+utime_SOURCES = utime.cc +utime_CXXFLAGS = -W -Wall -pedantic -O3 +utime_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src +utime_LDADD = $(top_builddir)/src/ranch-cxx/libranch-cxx.la
+tsc_SOURCES = tsc.cc +tsc_CXXFLAGS = -W -Wall -pedantic -O3 +tsc_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src +tsc_LDADD = $(top_builddir)/src/ranch-cxx/libranch-cxx.la Index: lib/cxx/demo/tsc.cc --- lib/cxx/demo/tsc.cc (revision 0) +++ lib/cxx/demo/tsc.cc (revision 0) @@ -0,0 +1,30 @@
+#include <ranch-cxx/ranch.hh>
+int do_something(int i) +{
- for (int j = 0; j < i; ++j)
- ;
- for (int j = 0; j < i; ++j)
- ;
- for (int j = 0; j < i; ++j)
- ;
- return i;
+}
+int main() +{
- Ranch::Input::Input dummy("dummy");
- Ranch::Inputs inputs;
- inputs.add(dummy);
- Ranch::Output::TSC tsc;
- Ranch::Outputs outputs;
- outputs.add(tsc);
- Ranch::Bencher b("TSC", inputs, outputs, "a comment");
- b.start(0.0f);
- do_something(1000000000);
- b.stop(tsc());
- return 0;
+} Index: lib/cxx/src/ranch-cxx/output/tsc.hxx --- lib/cxx/src/ranch-cxx/output/tsc.hxx (revision 0) +++ lib/cxx/src/ranch-cxx/output/tsc.hxx (revision 0) @@ -0,0 +1,20 @@
+#ifndef RANCH_OUTPUT_TSC_HXX +# define RANCH_OUTPUT_TSC_HXX
+# include <ranch-cxx/output/u-time.hh>
+namespace Ranch +{
- namespace Output
- {
- inline TSC::TSC() :
Output("TSC", "proc tick")
- {
- }
- } // namespace Output
+} // namespace Ranch
+#endif // !RANCH_OUTPUT_TSC_HXX Index: lib/cxx/src/ranch-cxx/output/all.hh --- lib/cxx/src/ranch-cxx/output/all.hh (revision 70) +++ lib/cxx/src/ranch-cxx/output/all.hh (working copy) @@ -3,6 +3,7 @@
# include <ranch-cxx/output/output.hh> # include <ranch-cxx/output/u-time.hh> +# include <ranch-cxx/output/tsc.hh>
#endif // !RANCH_OUTPUT_ALL_HH
Index: lib/cxx/src/ranch-cxx/output/tsc.hh --- lib/cxx/src/ranch-cxx/output/tsc.hh (revision 0) +++ lib/cxx/src/ranch-cxx/output/tsc.hh (revision 0) @@ -0,0 +1,32 @@
+#ifndef RANCH_OUTPUT_TSC_HH +# define RANCH_OUTPUT_TSC_HH
+# include <ranch-cxx/output/output.hh> +# include <stdint.h>
+namespace Ranch +{
- namespace Output
- {
- class TSC : public Output
- {
- public:
TSC();
- protected:
virtual void start_();
virtual void stop_();
uint64_t start_tsc_;
- }; // class Tsc
- } // namespace Output
+} // namespace Ranch
+# include <ranch-cxx/output/tsc.hxx>
+#endif // !RANCH_OUTPUT_TSC_HH
Index: lib/cxx/src/ranch-cxx/output/Makefile.am --- lib/cxx/src/ranch-cxx/output/Makefile.am (revision 70) +++ lib/cxx/src/ranch-cxx/output/Makefile.am (working copy) @@ -8,11 +8,16 @@ output.cc \ u-time.hh \ u-time.hxx \
- u-time.cc
- u-time.cc \
- tsc.hh \
- tsc.hxx \
- tsc.cc
pkgincludedir = $(includedir)/ranch-cxx/output pkginclude_HEADERS = \ all.hh \ output.hh \ output.hxx \ u-time.hh \
- u-time.hxx
- u-time.hxx \
- tsc.hh \
- tsc.hxx
Index: lib/cxx/src/ranch-cxx/output/tsc.cc --- lib/cxx/src/ranch-cxx/output/tsc.cc (revision 0) +++ lib/cxx/src/ranch-cxx/output/tsc.cc (revision 0) @@ -0,0 +1,28 @@ +#include <ranch-cxx/output/tsc.hh>
+namespace Ranch +{
- namespace Output
- {
- extern "C" __inline__ uint64_t read_tsc(void)
- {
uint64_t x;
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
return x;
- }
- void TSC::start_()
- {
start_tsc_ = read_tsc();
- }
- void TSC::stop_()
- {
value_ = (double)(read_tsc() - start_tsc_);
- }
- } // namespace Output
+} // namespace Ranch
Index: lib/cxx/src/ranch-cxx/bencher.hh --- lib/cxx/src/ranch-cxx/bencher.hh (revision 70) +++ lib/cxx/src/ranch-cxx/bencher.hh (working copy) @@ -66,7 +66,7 @@ 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.
- // Necessary to dump the scores once every excepted scores are registered. unsigned score_set_num_; // Necessary to manage add_score(double). Outputs::iterator cur_output_;