<commit_before>/*****************************************************************************\
 *                        ANALYSIS PERFORMANCE TOOLS                         *
 *                               libparaver-api                              *
 *                       Paraver Main Computing Library                      *
 *****************************************************************************
 *     ___     This library is free software; you can redistribute it and/or *
 *    /  __         modify it under the terms of the GNU LGPL as published   *
 *   /  /  _____    by the Free Software Foundation; either version 2.1      *
 *  /  /  /     \   of the License, or (at your option) any later version.   *
 * (  (  ( B S C )                                                           *
 *  \  \  \_____/   This library is distributed in 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 LGPL for more details.   *
 *                                                                           *
 * You should have received a copy of the GNU Lesser General Public License  *
 * along with this library; if not, write to the Free Software Foundation,   *
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA          *
 * The GNU LEsser General Public License is contained in the file COPYING.   *
 *                                 ---------                                 *
 *   Barcelona Supercomputing Center - Centro Nacional de Supercomputacion   *
\*****************************************************************************/

/* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- *\
 | @file: $HeadURL$
 | @last_commit: $Date$
 | @version:     $Revision$
\* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */

#include "kwindow.h"
#include "intervalcontrolderived.h"

KRecordList *IntervalControlDerived::init( TRecordTime initialTime, TCreateList create,
    KRecordList *displayList )
{
  TRecordTime myInitTime;
  SemanticHighInfo info;

  createList = create;
  currentValue = 0.0;

  if ( displayList == NULL )
    displayList = &myDisplayList;

  function = ( SemanticDerived * ) window->getSemanticFunction( level );

  setChilds();

  if ( begin != NULL )
  {
    delete begin;
    begin = NULL;
  }
  if ( end != NULL )
  {
    delete end;
    end = NULL;
  }

  if ( function->getInitFromBegin() )
    myInitTime = 0.0;
  else
    myInitTime = initialTime;

  info.callingInterval = this;

  childIntervals[ 0 ]->init( myInitTime, createList, displayList );
  childIntervals[ 1 ]->init( myInitTime, createList, displayList );

  if ( window->getLevel() >= SYSTEM )
  {
    begin = window->copyCPUIterator( childIntervals[ 0 ]->getBegin() );
    end = window->copyCPUIterator( childIntervals[ 0 ]->getEnd() );
  }
  else
  {
    begin = window->copyThreadIterator( childIntervals[ 0 ]->getBegin() );
    end = window->copyThreadIterator( childIntervals[ 0 ]->getEnd() );
  }

  while ( childIntervals[ 1 ]->getEnd()->getTime() <= begin->getTime() )
    childIntervals[ 1 ]->calcNext( displayList );

  if ( childIntervals[ 1 ]->getEnd()->getTime() > begin->getTime() )
  {
    info.values.clear();
    info.values.push_back( currentValue );
    info.values.push_back( childIntervals[ 1 ]->getValue() *
                           window->getFactor( 1 ) );
    currentValue = function->execute( &info );
  }

  while ( childIntervals[ 1 ]->getEnd()->getTime() < end->getTime() )
  {
    childIntervals[ 1 ]->calcNext( displayList );
    info.values.clear();
    info.values.push_back( currentValue );
    info.values.push_back( childIntervals[ 1 ]->getValue() *
                           window->getFactor( 1 ) );
    currentValue = function->execute( &info );
  }

  while ( end->getTime() < initialTime )
    calcNext( displayList );

  return displayList;
}


KRecordList *IntervalControlDerived::calcNext( KRecordList *displayList, bool initCalc )
{
  SemanticHighInfo info;

  currentValue = 0;

  if ( displayList == NULL )
    displayList = &myDisplayList;

  if ( begin != NULL )
  {
    delete begin;
    begin = NULL;
  }
  if ( end != NULL )
  {
    delete end;
    end = NULL;
  }

  info.callingInterval = this;

  childIntervals[ 0 ]->calcNext( displayList );

  if ( window->getLevel() >= SYSTEM )
  {
    begin = window->copyCPUIterator( childIntervals[ 0 ]->getBegin() );
    end = window->copyCPUIterator( childIntervals[ 0 ]->getEnd() );
  }
  else
  {
    begin = window->copyThreadIterator( childIntervals[ 0 ]->getBegin() );
    end = window->copyThreadIterator( childIntervals[ 0 ]->getEnd() );
  }

  while ( childIntervals[ 1 ]->getEnd()->getTime() <= begin->getTime() )
    childIntervals[ 1 ]->calcNext( displayList );

  if ( childIntervals[ 1 ]->getEnd()->getTime() > begin->getTime() )
  {
    info.values.clear();
    info.values.push_back( currentValue );
    info.values.push_back( childIntervals[ 1 ]->getValue() *
                           window->getFactor( 1 ) );
    currentValue = function->execute( &info );
  }

  while ( childIntervals[ 1 ]->getEnd()->getTime() < end->getTime() )
  {
    childIntervals[ 1 ]->calcNext( displayList );
    info.values.clear();
    info.values.push_back( currentValue );
    info.values.push_back( childIntervals[ 1 ]->getValue() *
                           window->getFactor( 1 ) );
    currentValue = function->execute( &info );
  }
<commit_msg>*** empty log message ***<commit_after>/*****************************************************************************\
 *                        ANALYSIS PERFORMANCE TOOLS                         *
 *                               libparaver-api                              *
 *                       Paraver Main Computing Library                      *
 *****************************************************************************
 *     ___     This library is free software; you can redistribute it and/or *
 *    /  __         modify it under the terms of the GNU LGPL as published   *
 *   /  /  _____    by the Free Software Foundation; either version 2.1      *
 *  /  /  /     \   of the License, or (at your option) any later version.   *
 * (  (  ( B S C )                                                           *
 *  \  \  \_____/   This library is distributed in 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 LGPL for more details.   *
 *                                                                           *
 * You should have received a copy of the GNU Lesser General Public License  *
 * along with this library; if not, write to the Free Software Foundation,   *
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA          *
 * The GNU LEsser General Public License is contained in the file COPYING.   *
 *                                 ---------                                 *
 *   Barcelona Supercomputing Center - Centro Nacional de Supercomputacion   *
\*****************************************************************************/

/* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- *\
 | @file: $HeadURL$
 | @last_commit: $Date$
 | @version:     $Revision$
\* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */

#include "kwindow.h"
#include "intervalcontrolderived.h"

KRecordList *IntervalControlDerived::init( TRecordTime initialTime, TCreateList create,
    KRecordList *displayList )
{
  TRecordTime myInitTime;
  SemanticHighInfo info;

  createList = create;
  currentValue = 0.0;

  if ( displayList == NULL )
    displayList = &myDisplayList;

  function = ( SemanticDerived * ) window->getSemanticFunction( level );

  setChilds();

  if ( begin != NULL )
  {
    delete begin;
    begin = NULL;
  }
  if ( end != NULL )
  {
    delete end;
    end = NULL;
  }

  if ( function->getInitFromBegin() )
    myInitTime = 0.0;
  else
    myInitTime = initialTime;

  info.callingInterval = this;

  childIntervals[ 0 ]->init( myInitTime, createList, displayList );
  childIntervals[ 1 ]->init( myInitTime, createList, displayList );

  if ( window->getLevel() >= SYSTEM )
  {
    begin = window->copyCPUIterator( childIntervals[ 0 ]->getBegin() );
    end = window->copyCPUIterator( childIntervals[ 0 ]->getEnd() );
  }
  else
  {
    begin = window->copyThreadIterator( childIntervals[ 0 ]->getBegin() );
    end = window->copyThreadIterator( childIntervals[ 0 ]->getEnd() );
  }

  while ( childIntervals[ 1 ]->getEnd()->getTime() <= begin->getTime() )
    childIntervals[ 1 ]->calcNext( displayList );

  if ( childIntervals[ 1 ]->getEnd()->getTime() > begin->getTime() )
  {
    info.values.clear();
    info.values.push_back( currentValue );
    info.values.push_back( childIntervals[ 1 ]->getValue() *
                           window->getFactor( 1 ) );
    currentValue = function->execute( &info );
  }

  while ( childIntervals[ 1 ]->getEnd()->getTime() < end->getTime() )
  {
    childIntervals[ 1 ]->calcNext( displayList );
    info.values.clear();
    info.values.push_back( currentValue );
    info.values.push_back( childIntervals[ 1 ]->getValue() *
                           window->getFactor( 1 ) );
    currentValue = function->execute( &info );
  }

  while ( end->getTime() < initialTime )
    calcNext( displayList );

  return displayList;
}


KRecordList *IntervalControlDerived::calcNext( KRecordList *displayList, bool initCalc )
{
  SemanticHighInfo info;

  currentValue = 0;

  if ( displayList == NULL )
    displayList = &myDisplayList;

  if ( begin != NULL )
  {
    delete begin;
    begin = NULL;
  }
  if ( end != NULL )
  {
    delete end;
    end = NULL;
  }

  info.callingInterval = this;

  childIntervals[ 0 ]->calcNext( displayList );

  if ( window->getLevel() >= SYSTEM )
  {
    begin = window->copyCPUIterator( childIntervals[ 0 ]->getBegin() );
    end = window->copyCPUIterator( childIntervals[ 0 ]->getEnd() );
  }
  else
  {
    begin = window->copyThreadIterator( childIntervals[ 0 ]->getBegin() );
    end = window->copyThreadIterator( childIntervals[ 0 ]->getEnd() );
  }

  if( begin->getTime() == window->getTrace()->getEndTime() )
    return displayList;

  while ( childIntervals[ 1 ]->getEnd()->getTime() <= begin->getTime() )
    childIntervals[ 1 ]->calcNext( displayList );

  if ( childIntervals[ 1 ]->getEnd()->getTime() > begin->getTime() )
  {
    info.values.clear();
    info.values.push_back( currentValue );
    info.values.push_back( childIntervals[ 1 ]->getValue() *
                           window->getFactor( 1 ) );
    currentValue = function->execute( &info );
  }

  while ( childIntervals[ 1 ]->getEnd()->getTime() < end->getTime() )
  {
    childIntervals[ 1 ]->calcNext( displayList );
    info.values.clear();
    info.values.push_back( currentValue );
    info.values.push_back( childIntervals[ 1 ]->getValue() *
                           window->getFactor( 1 ) );
    currentValue = function->execute( &info );
  }

{'fraction_non_alphanumeric': 0.18545679448665842, 'fraction_numerical': 0.008305354302880368, 'mean_word_length': 2.252586206896552, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 130, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1660948', 'n_tokens_mistral': 3416, 'n_tokens_neox': 3168, 'n_words': 799}