<commit_before>/*
 * Copyright 2010,
 * <NAME>,
 * <NAME>,
 *
 * CNRS/AIST
 *
 * This file is part of sot-core.
 * sot-core is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 * sot-core is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.  You should
 * have received a copy of the GNU Lesser General Public License along
 * with sot-core.  If not, see <http://www.gnu.org/licenses/>.
 */

/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */

/* SOT */
#include <sot/core/timer.hh>
#include <dynamic-graph/linear-algebra.h>
#include <sot/core/matrix-geometry.hh>
#include <sot/core/factory.hh>

using namespace dynamicgraph::sot;
using namespace dynamicgraph;

/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */

typedef Timer<dynamicgraph::Vector> timevect;
template <> 
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(timevect,"Timer<Vector>");

typedef Timer<dynamicgraph::Matrix> timematrix;
template <> 
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(timematrix,"Timer<Matrix>");

typedef Timer<MatrixHomogeneous> timematrixhomo;
template <> 
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(timematrixhomo,"Timer<MatrixHomo>");

typedef Timer<double> timedouble;
template <> 
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(timedouble,"Timer<double>");


/* --------------------------------------------------------------------- */
void 
cmdChrono( const std::string& cmdLine,
	   std::istringstream& cmdArg,
	   std::ostream& os )
{
  sotDEBUGIN(15);

  if( cmdLine == "help" ) 
    {
      os << "  - chrono <cmd...>"
	 << "\t\t\t\tLaunch <cmd> and display the time spent in the operation." <<std::endl;
      return;
    }
  
  struct timeval t0,t1;
  double dt;

  gettimeofday(&t0,NULL);
  sotDEBUG(15) << "t0: "<< t0.tv_sec << " - " << t0.tv_usec << std::endl;
  
  std::string cmdLine2;  cmdArg>>cmdLine2;
  sotDEBUG(5)<<"Chrono <" <<cmdLine2<<">"<<std::endl;
  // Florent: remove reference to g_shell
  //g_shell.cmd(cmdLine2,cmdArg,os);

  gettimeofday(&t1,NULL);<commit_msg>Make the timers available in Python.<commit_after>/*
 * Copyright 2010,
 * <NAME>,
 * <NAME>,
 *
 * CNRS/AIST
 *
 * This file is part of sot-core.
 * sot-core is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 * sot-core is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.  You should
 * have received a copy of the GNU Lesser General Public License along
 * with sot-core.  If not, see <http://www.gnu.org/licenses/>.
 */

/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */

/* SOT */
#include <sot/core/timer.hh>
#include <dynamic-graph/linear-algebra.h>
#include <sot/core/matrix-geometry.hh>
#include <sot/core/factory.hh>

using namespace dynamicgraph::sot;
using namespace dynamicgraph;

/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */

typedef Timer<dynamicgraph::Vector> timevect;
template <> 
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(timevect,"TimerVector");

typedef Timer<dynamicgraph::Matrix> timematrix;
template <> 
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(timematrix,"TimerMatrix");

typedef Timer<MatrixHomogeneous> timematrixhomo;
template <> 
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(timematrixhomo,"TimerMatrixHomo");

typedef Timer<double> timedouble;
template <> 
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(timedouble,"TimerDouble");


/* --------------------------------------------------------------------- */
void 
cmdChrono( const std::string& cmdLine,
	   std::istringstream& cmdArg,
	   std::ostream& os )
{
  sotDEBUGIN(15);

  if( cmdLine == "help" ) 
    {
      os << "  - chrono <cmd...>"
	 << "\t\t\t\tLaunch <cmd> and display the time spent in the operation." <<std::endl;
      return;
    }
  
  struct timeval t0,t1;
  double dt;

  gettimeofday(&t0,NULL);
  sotDEBUG(15) << "t0: "<< t0.tv_sec << " - " << t0.tv_usec << std::endl;
  
  std::string cmdLine2;  cmdArg>>cmdLine2;
  sotDEBUG(5)<<"Chrono <" <<cmdLine2<<">"<<std::endl;
  // Florent: remove reference to g_shell
  //g_shell.cmd(cmdLine2,cmdArg,os);

  gettimeofday(&t1,NULL);
{'fraction_non_alphanumeric': 0.2862217236866704, 'fraction_numerical': 0.007851934941110488, 'mean_word_length': 1.96398891966759, 'pattern_counts': {'":': 0, '<': 91, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2315550', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1522, 'n_words': 402}