Example #1
0
TimeSpan DayTime::To ( const self_t& _time_to ) const
{
    if ( _time_to.m_Milliseconds < this->m_Milliseconds )
        return TimeSpan ( int64(_time_to.m_Milliseconds + DayTime::msecs_per_day - this->m_Milliseconds) * 1000 );
    else
        return TimeSpan( int64(_time_to.m_Milliseconds - this->m_Milliseconds) * 1000 ); 
}
Example #2
0
TimeSpan Time::AppDuration()
{
	static LARGE_INTEGER freq;
	static LARGE_INTEGER start;
	static int state = 0; // 0=not initialized, -1=not supported, 1=supported

	if (state == 0)
	{
		if (QueryPerformanceFrequency(&freq) == 0)
		{
			state = -1;
		}
		else
		{
			QueryPerformanceCounter(&start);
			state = 1;
		}
	}

	// Not supported, use tick count.
	if (state == -1)
	{
		return TimeSpan(GetTickCount());
	}
	else
	{
		LARGE_INTEGER tickCount;
		QueryPerformanceCounter(&tickCount);

		LONGLONG f = freq.QuadPart / 1000;
		return TimeSpan((tickCount.QuadPart - start.QuadPart) / f);
	}
}
TimeSpan TimeZone::GetUtcOffset(const DateTime& dt) const
{
   if (!IsDaylightSavingTime(dt))
      return TimeSpan(0, -(m_tzi.Bias + m_tzi.StandardBias), 0, 0);
   else
      return TimeSpan(0, -(m_tzi.Bias + m_tzi.DaylightBias), 0, 0);
}
Example #4
0
void TimeListDialog::updateWalker(TimeListTimeWalker &walker, CalendarTimeSpan *span){
    // TODO: maybe also track of the tasks done in the given year/month/day and display them as list?
    QDate start = span->start().date();

    if(start.year() != walker.year){
        updateItemWithDuration(walker.yearItem, walker.yearDuration);
        walker.yearDuration = TimeSpan();

        walker.yearItem = new QTreeWidgetItem(ui->treeWidget, QStringList{QString::number(start.year())});
        walker.year = start.year();
        walker.month = -1;
        walker.day = -1;
    }
    if(start.month() != walker.month){
        updateItemWithDuration(walker.monthItem, walker.monthDuration);
        walker.monthDuration = TimeSpan();

        QString name = QDate::longMonthName(start.month(), QDate::StandaloneFormat);
        walker.monthItem = new QTreeWidgetItem(walker.yearItem, QStringList{name});
        walker.month = start.month();
        walker.day = -1;
    }
    if(start.day() != walker.day){
        updateItemWithDuration(walker.dayItem, walker.dayDuration);
        walker.dayDuration = TimeSpan();

        walker.dayItem = new QTreeWidgetItem(walker.monthItem, QStringList{start.toString("d. MMMM")});
        walker.day = start.day();
    }
    walker.dayDuration += span->duration();
    walker.monthDuration += span->duration();
    walker.yearDuration += span->duration();
}
Example #5
0
void TimeListDialog::updateTree(){
    if(mCurrentTask == NULL) return;
    bool recursive =  ui->recursive->isChecked();
    ui->treeWidget->clear();
    ui->summary->setText(mCurrentTask->summary());
    ui->timeSpent->setText(mCurrentTask->duration(recursive).description(TimeSpan::MAX_DETAIL));

    ui->treeWidget->setColumnCount(recursive ? 4 : 3);
    QStringList headerLabels{tr("Start"), tr("Duration"), tr("End")};
    if(recursive)
        headerLabels.append(tr("Task"));
    ui->treeWidget->setHeaderLabels(headerLabels);
    ui->treeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
    ui->treeWidget->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
    ui->treeWidget->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
    if(recursive)
        ui->treeWidget->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);

    // Walk throught the time spans and create the tree structure (with nodes for years, months, days and spans).
    // The `walker` keeps track of the name we are in now.
    TimeListTimeWalker walker = {
        -1, NULL, TimeSpan(),
        -1, NULL, TimeSpan(),
        -1, NULL, TimeSpan(),
    };

    QFont italic;
    italic.setItalic(true);

    for(auto span: mCurrentTask->timeSpans(recursive)){
        updateWalker(walker, span);
        QTreeWidgetItem* item = new QTreeWidgetItem(walker.dayItem);
        item->setData(0, Qt::DisplayRole, span->start().time());
        item->setData(1, Qt::DisplayRole, span->duration().description());
        if(span->isFix()){
            item->setData(2, Qt::DisplayRole, tr("Time Fix"));
            item->setData(2, Qt::FontRole, italic);
        }else{
            // display only time (not date) if the start date is the same as end date
            if(span->start().date() != span->end().date()){
                item->setData(2, Qt::DisplayRole, span->end());
            }else{
                item->setData(2, Qt::DisplayRole, span->end().time());
            }
        }
        if(recursive){
            item->setData(3, Qt::DisplayRole, span->task()->summary());
        }
    }

    updateItemWithDuration(walker.yearItem, walker.yearDuration);
    updateItemWithDuration(walker.monthItem, walker.monthDuration);
    updateItemWithDuration(walker.dayItem, walker.dayDuration);
}
Example #6
0
// read solution status -----------------------------------------------------
void __fastcall TPlot::ReadSolStat(TStrings *files, int sel)
{
    AnsiString s;
    gtime_t ts,te;
    double tint;
    int i,n=0;
    char *paths[MAXNFILE],id[32];
    
    trace(3,"ReadSolStat\n");
    
    freesolstatbuf(SolStat+sel);
    
    for (i=0;i<MAXNFILE;i++) paths[i]=path_str[i];
    
    TimeSpan(&ts,&te,&tint);
    
    for (i=0;i<files->Count&&n<MAXNFILE;i++) {
        strcpy(paths[n++],U2A(files->Strings[i]).c_str());
    }
    ShowMsg(s.sprintf("reading %s...",paths[0]));
    ShowLegend(NULL);
    
    readsolstatt(paths,n,ts,te,tint,SolStat+sel);
    
    UpdateSatList();
}
Example #7
0
    void Stopwatch::Reset()
    {
        _elapsed = TimeSpan();

        if (_isRunning)
            _start = ReadTimer();
    }
 void
 IBeamTool::on_button_press_event (GdkEventButton* event)
 {
   Tool::on_button_press_event(event);
   shared_ptr<TimelineState> state = get_state();
   
   if (event->button == 1)
     {
       const Time time = state->getViewWindow().x_to_time(event->x);
       
       if (is_mouse_in_start_drag_zone())
         {
           // User began to drag the start of the selection
           dragType = GrabStart;
           pinnedDragTime = state->getSelectionEnd();
         }
       else
       if (is_mouse_in_end_drag_zone())
         {
           // User began to drag the end of the selection
           dragType = GrabEnd;
           pinnedDragTime = state->getSelectionStart();
         }
       else
         {
           // User began the drag in clear space, begin a Select drag
           dragType = Selection;
           pinnedDragTime = time;
           selectionControl (TimeSpan(time, Duration::NIL));
         }
     }
 }
Example #9
0
	TimeSpan World::CurrentDayTime::get()
	{
		int hour = Native::Function::Call<int>(Native::Hash::GET_CLOCK_HOURS);
		int minute = Native::Function::Call<int>(Native::Hash::GET_CLOCK_MINUTES);
		int second = Native::Function::Call<int>(Native::Hash::GET_CLOCK_SECONDS);

		return TimeSpan(hour, minute, second);
	}
Example #10
0
 T dequeue(TimeSpan pTime = TimeSpan())
 {
     QMutexLocker lock(&mMutex);
     if (mQueue.size() > 0) return mQueue.dequeue();
     mCond.wait(&mMutex, pTime.totalMsec());
     if (mQueue.size() > 0) return mQueue.dequeue();
     else return T();
 }
Example #11
0
// read observation data rinex ----------------------------------------------
int __fastcall TPlot::ReadObsRnx(TStrings *files, obs_t *obs, nav_t *nav,
                                 sta_t *sta)
{
    AnsiString s;
    gtime_t ts,te;
    double tint;
    int i;
    char obsfile[1024],navfile[1024],*p,*opt=RnxOpts.c_str();
    
    trace(3,"ReadObsRnx\n");
    
    TimeSpan(&ts,&te,&tint);
    
    for (i=0;i<files->Count;i++) {
        strcpy(obsfile,U2A(files->Strings[i]).c_str());
        
        ShowMsg(s.sprintf("reading obs data... %s",obsfile));
        Application->ProcessMessages();
        
        if (readrnxt(obsfile,1,ts,te,tint,opt,obs,nav,sta)<0) {
            ShowMsg("error: insufficient memory");
            return -1;
        }
    }
    ShowMsg("reading nav data...");
    Application->ProcessMessages();
    
    for (i=0;i<files->Count;i++) {
        strcpy(navfile,U2A(files->Strings[i]).c_str());
        
        if (!(p=strrchr(navfile,'.'))) continue;
        
        if (!strcmp(p,".obs")||!strcmp(p,".OBS")) {
            strcpy(p,".nav" ); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p,".gnav"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p,".hnav"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p,".qnav"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p,".lnav"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
        }
        else if (!strcmp(p+3,"o" )||!strcmp(p+3,"d" )||
                 !strcmp(p+3,"O" )||!strcmp(p+3,"D" )) {
            strcpy(p+3,"N"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p+3,"G"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p+3,"H"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p+3,"Q"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p+3,"L"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
            strcpy(p+3,"P"); readrnxt(navfile,1,ts,te,tint,opt,NULL,nav,NULL);
        }
    }
    if (obs->n<=0) {
        ShowMsg(s.sprintf("no observation data: %s...",files->Strings[0].c_str()));
        freenav(nav,0xFF);
        return 0;
    }
    uniqnav(nav);
    return sortobs(obs);
}
Example #12
0
 TimeSpan DateTime::operator-(const DateTime & dt) const
 {
   int secs = m_date.tv_sec - dt.m_date.tv_sec;
   int usecs = m_date.tv_usec - dt.m_date.tv_usec;
   int mins = secs / 60;
   secs %= 60;
   int hrs = mins / 60;
   mins %= 60;
   int days = hrs / 24;
   hrs %= 24;
   return TimeSpan(days, hrs, mins, secs, usecs);
 }
CString DateTime::FormatISO8601(T_enISO8601Format enFormat, bool bBasic, const TimeZone& tz) const throw()
{
   CString cszDate;
   switch(enFormat)
   {
   case formatY:  return Format(_T("%Y"), tz);
   case formatYM: return Format(bBasic ? _T("%Y%m") : _T("%Y-%m"), tz);
   case formatYMD: return Format(bBasic ? _T("%Y%m%d") : _T("%Y-%m-%d"), tz);
   case formatYMD_HM_Z:
      cszDate = Format(bBasic ? _T("%Y%m%dT%H%M") : _T("%Y-%m-%dT%H:%M"), tz);
      break;

   case formatYMD_HMS_Z:
      cszDate = Format(bBasic ? _T("%Y%m%dT%H%M%S") : _T("%Y-%m-%dT%H:%M:%S"), tz);
      break;

   case formatYMD_HMSF_Z:
      {
         cszDate = Format(bBasic ? _T("%Y%m%dT%H%M%S") : _T("%Y-%m-%dT%H:%M:%S"), tz);

         CString cszFraction;
         cszFraction.Format(_T(".%03u"), Millisecond());
         cszDate += cszFraction;
      }
      break;
   }

   // add timezone
   if (tz.StandardName() == _T("UTC"))
      cszDate += _T("Z");
   else
   {
      TimeSpan spTimezone = tz.GetUtcOffset(*this);
      bool bNegative = spTimezone < TimeSpan(0, 0, 0, 0);

      TimeSpan spTimezoneAbs = bNegative ? -spTimezone : spTimezone;

      CString cszTimezone;
      cszTimezone.Format(bBasic ? _T("%c%02u%02u") : _T("%c%02u:%02u"),
         !bNegative ? _T('+') : _T('-'),
         spTimezoneAbs.Hours(),
         spTimezoneAbs.Minutes());

      cszDate += cszTimezone;
   }

   return cszDate;
}
Example #14
0
void GameTime::updateGameTime()
{
	QueryPerformanceCounter(&_Query);
	curTicks = _Query.QuadPart;
	if ((UINT64) ((float)(curTicks - lastTicks )/ _freQuery)   <  TimeSpan::TicksPerMilisecond * 16)
	{
		return;
	}
	auto gt = ((float)(curTicks - lastTicks)) / _freQuery;
	this->setTotalGameTime( _totalGameTime + gt);
	this->setElapsedGameTime(
		TimeSpan((UINT64) gt)
		);
	lastTicks = curTicks;
	
}
 void
 IBeamTool::set_leading_x (const int x)
 {
   shared_ptr<TimelineState> state = get_state();
   
   // The line below needs handled differently now;  ////////////TODO GTK-3
   //
   //const bool set_playback_period = dragType == Selection;
   
   TimeVar newStartPoint (state->getViewWindow().x_to_time(x));
   Offset selectionLength (pinnedDragTime, newStartPoint);
   
   if (newStartPoint > pinnedDragTime)
     newStartPoint=pinnedDragTime; // use the smaller one as selection start
   
   selectionControl (TimeSpan (newStartPoint, Duration(selectionLength)));
 }
Example #16
0
// read navigation data -----------------------------------------------------
void __fastcall TPlot::ReadNav(TStrings *files)
{
    AnsiString s;
    gtime_t ts,te;
    double tint;
    char navfile[1024],*opt=RnxOpts.c_str();
    int i;
    
    trace(3,"ReadNav\n");
    
    if (files->Count<=0) return;
    
    ReadWaitStart();
    ShowLegend(NULL);
    
    TimeSpan(&ts,&te,&tint);
    
    freenav(&Nav,0xFF);
    
    ShowMsg("reading nav data...");
    Application->ProcessMessages();
    
    for (i=0;i<files->Count;i++) {
        strcpy(navfile,U2A(files->Strings[i]).c_str());
        readrnxt(navfile,1,ts,te,tint,opt,NULL,&Nav,NULL);
    }
    uniqnav(&Nav);
    
    if (Nav.n<=0&&Nav.ng<=0&&Nav.ns<=0) {
        ShowMsg(s.sprintf("no nav message: %s...",files->Strings[0].c_str()));
        ReadWaitEnd();
        return;
    }
    if (NavFiles!=files) {
        NavFiles->Assign(files);
    }
    UpdateObs(NObs);
    UpdateMp();
    ReadWaitEnd();
    
    UpdatePlot();
}
Example #17
0
Ptr<Texture> Filter::Apply(Ptr<Texture> input)
{
    Input = input;
    TotalTime = RenderTime = CompileTime = TimeSpan(0);
    assert(Input);
#ifdef PROFILING
    glFinish();
    auto t = now();
#endif
    DoLoadShaderPrograms();
    DoInitialize();
    auto output = PerformSteps();
#ifdef PROFILING
    TotalTime = now() - t;
    PrintProfilingInfo();
    RenderWindow::CompileTime += CompileTime;
    RenderWindow::RenderTime  += RenderTime;
#endif
    return output;
}
Example #18
0
void EventView::timeSpansChanged()
{
    m_timeSpans = TimeSpans(QDate::currentDate()).standardTimeSpans();
    // close enough to "ever" for our purposes:
    NamedTimeSpan allEvents = {
        tr("Ever"),
        TimeSpan(QDate::currentDate().addYears(-200),
                 QDate::currentDate().addYears(+200)),
        Range
    };
    m_timeSpans << allEvents;

    const int currentIndex = m_comboBox->currentIndex();
    m_comboBox->clear();
    for (int i = 0; i < m_timeSpans.size(); ++i)
        m_comboBox->addItem(m_timeSpans[i].name);
    if (currentIndex >= 0 && currentIndex <= m_timeSpans.size()) {
        m_comboBox->setCurrentIndex(currentIndex);
    } else {
        m_comboBox->setCurrentIndex(0);
    }
}
Example #19
0
    GpuTimer::GpuTimer(
        const UINT nFrames,
        const std::vector<const char*>& timeSpanNames,
        ID3D12Device* pDevice,
        ID3D12CommandQueue* pCmdQueue,
        const BOOL setStablePowerState /*= FALSE*/ )
    {
        // Initialize m_timeSpans.
        //for( auto& span : timeSpanNames )
        for( auto i = 0; i < timeSpanNames.size(); ++i )
        {
            m_timeSpans[ timeSpanNames[ i ] ] = TimeSpan( i );
            //m_timeSpans[ i ].name = timeSpanNames[ i ];
        }

        // nFrames timestamps for each frame.
        const UINT resultCount = 2 * timeSpanNames.size() * nFrames;
        const UINT resultBufferSize = resultCount * sizeof( UINT64 );

        D3D12_QUERY_HEAP_DESC timestampHeapDesc = {};
        timestampHeapDesc.Type = D3D12_QUERY_HEAP_TYPE_TIMESTAMP;
        timestampHeapDesc.Count = resultCount;

        //for( UINT i = 0; i < GraphicsAdaptersCount; i++ )
        {
            createCommittedReadbackBuffer(
                pDevice,
                m_timestampResultBuffer,
                resultBufferSize );

            ThrowIfFailed( pDevice->CreateQueryHeap( &timestampHeapDesc, IID_PPV_ARGS( &m_timestampQueryHeap ) ) );
        }

        // Set the stable power state on the device as necessary.
        ThrowIfFailed( pDevice->SetStablePowerState( setStablePowerState ) );

        // Get the timestamp frequency of the compute command queue.
        ThrowIfFailed( pCmdQueue->GetTimestampFrequency( &m_timestampFrequency ) );
    }
TimeSpan DateTime::operator-(const DateTime& right) {
  return TimeSpan(unixtime()-right.unixtime());
}
Example #21
0
/**
  Set a new alarm with given hours, minutes and seconds from current time.
*/
void Clock::SetAlarm(int hoursFromNow, int minutesFromNow, int secondsFromNow){
  _alarm = DateTime(rtc.now() + TimeSpan(0, hoursFromNow, minutesFromNow, secondsFromNow));
  _alarmIsRunning = true;
}
Example #22
0
 TimeSpan TimeSpan::Seconds(uint64 seconds)            { return TimeSpan(static_cast<uint64>(seconds)        * 1000000000); }
void StatisticsWriterHtml::Write(const Statistics *stats)
{
  *stream() <<
  "<!DOCTYPE html>\n"
  "<html>\n"
  "<head>\n"
  "  <title>" << "Profile of '" << script_name() << "'</title>\n"
  "  <script type=\"text/javascript\"\n"
  "          src=\"http://code.jquery.com/jquery-latest.min.js\">\n"
  "  </script>\n"
  "  <script type=\"text/javascript\"\n"
  "          src=\"http://tablesorter.com/__jquery.tablesorter.min.js\">\n"
  "  </script>\n"
  "  <script type=\"text/javascript\">\n"
  "    $(document).ready(function() {\n"
  "      $('#data').tablesorter();\n"
  "    });\n"
  "  </script>\n"
  "</head>\n"
  "<body>\n"
  ;

  *stream() <<
  "  <style type=\"text/css\">\n"
  "    table {\n"
  "      border-spacing: 0;\n"
  "      border-collapse: collapse;\n"
  "    }\n"
  "    table#data {\n"
  "      width: 100%;\n"
  "    }\n"
  "    table, th, td {\n"
  "      border-width: thin;\n"
  "      border-style: solid;\n"
  "      border-color: #aaaaaa;\n"
  "    }\n"
  "    th {\n"
  "      text-align: left;\n"
  "      background-color: #cccccc;\n"
  "    }\n"
  "    th.group {\n"
  "      text-align: center;\n"
  "    }\n"
  "    td {\n"
  "      text-align: left;\n"
  "      font-family: Consolas, \"DejaVu Sans Mono\", \"Courier New\", Monospace;\n"
  "    }\n"
  "    tbody tr:nth-child(odd) {\n"
  "      background-color: #eeeeee;\n"
  "    }\n"
  "    tbody tr:hover {\n"
  "      background-color: #c0e3eb;\n"
  "    }\n"
  "  </style>\n"
  "  <table id=\"meta\">\n"
  "    <thead>\n"
  "      <tr>\n"
  "        <th>Name</th>\n"
  "        <th>Value</th>\n"
  "      </tr>\n"
  "    </thead>\n"
  "    <tbody>\n"
  ;

  if (print_date()) {
    *stream() <<
    "      <tr>\n"
    "        <td>Date</td>\n"
    "        <td>" << CTime() << "</td>\n"
    "      </tr>\n"
    ;
  }

  if (print_run_time()) {
    *stream() <<
    "      <tr>\n"
    "        <td>Duration</td>\n"
    "        <td>" << TimeSpan(stats->GetTotalRunTime()) << "</td>\n"
    "      </tr>\n"
    ;
  }

  *stream() <<
  "    </tbody>\n"
  "  </table>\n"
  "  <br/>\n"
  "  <table id=\"data\" class=\"tablesorter\">\n"
  "    <thead>\n"
  "      <tr>\n"
  "        <th rowspan=\"2\">Type</th>\n"
  "        <th rowspan=\"2\">Name</th>\n"
  "        <th rowspan=\"2\">Calls</th>\n"
  "        <th colspan=\"4\" class=\"group\">Self Time</th>\n"
  "        <th colspan=\"4\" class=\"group\">Total Time</th>\n"
  "      </tr>\n"
  "      <tr>\n"
  "        <th>%</th>\n"
  "        <th>Overall</th>\n"
  "        <th>Average</th>\n"
  "        <th>Worst</th>\n"
  "        <th>%</th>\n"
  "        <th>Overall</th>\n"
  "        <th>Average</th>\n"
  "        <th>Worst</th>\n"
  "      </tr>\n"
  "    </thead>\n"
  "    <tbody>\n"
  ;

  std::vector<FunctionStatistics*> all_fn_stats;
  stats->GetStatistics(all_fn_stats);

  Nanoseconds self_time_all;
  for (std::vector<FunctionStatistics*>::const_iterator iterator = all_fn_stats.begin();
       iterator != all_fn_stats.end(); ++iterator)
  {
    const FunctionStatistics *fn_stats = *iterator;
    self_time_all += fn_stats->self_time();
  };

  Nanoseconds total_time_all;
  for (std::vector<FunctionStatistics*>::const_iterator iterator = all_fn_stats.begin();
       iterator != all_fn_stats.end(); ++iterator)
  {
    const FunctionStatistics *fn_stats = *iterator;
    total_time_all += fn_stats->total_time();
  };

  std::ostream::fmtflags flags = stream()->flags();
  stream()->flags(flags | std::ostream::fixed);

  for (std::vector<FunctionStatistics*>::const_iterator iterator = all_fn_stats.begin();
       iterator != all_fn_stats.end(); ++iterator)
  {
    const FunctionStatistics *fn_stats = *iterator;

    double self_time_percent = fn_stats->self_time().count() * 100 / self_time_all.count();
    double total_time_percent = fn_stats->total_time().count() * 100 / total_time_all.count();

    double self_time = Seconds(fn_stats->self_time()).count();
    double total_time = Seconds(fn_stats->total_time()).count();

    double avg_self_time = Milliseconds(fn_stats->self_time()).count() / fn_stats->num_calls();
    double avg_total_time = Milliseconds(fn_stats->total_time()).count() / fn_stats->num_calls();

    double worst_self_time = Milliseconds(fn_stats->worst_self_time()).count();
    double worst_total_time = Milliseconds(fn_stats->worst_total_time()).count();

    *stream()
    << "    <tr>\n"
    << "      <td>" << fn_stats->function()->GetTypeString() << "</td>\n"
    << "      <td>" << fn_stats->function()->name() << "</td>\n"
    << "      <td>" << fn_stats->num_calls() << "</td>\n"
    << "      <td>" << std::setprecision(2) << self_time_percent << "%</td>\n"
    << "      <td>" << std::setprecision(1) << self_time << "</td>\n"
    << "      <td>" << std::setprecision(1) << avg_self_time << "</td>\n"
    << "      <td>" << std::setprecision(1) << worst_self_time << "</td>\n"
    << "      <td>" << std::setprecision(2) << total_time_percent << "%</td>\n"
    << "      <td>" << std::setprecision(1) << total_time << "</td>\n"
    << "      <td>" << std::setprecision(1) << avg_total_time << "</td>\n"
    << "      <td>" << std::setprecision(1) << worst_total_time << "</td>\n"
    << "    </tr>\n";
  };

  stream()->flags(flags);

  *stream() <<
  "    </tbody>\n"
  "  </table>\n"
  "</body>\n"
  "</html>\n"
  ;
}
Example #24
0
 TimeSpan TimeSpan::Minutes(int minutes)                { return TimeSpan(static_cast<uint64>(minutes)        * 1000000000 * 60); }
TimeSpan DateTime::TimeOfDay() throw()
{
   return TimeSpan(Hour(), Minute(), Second(), Millisecond());
}
Example #26
0
 TimeSpan TimeSpan::Hours(int hours)                    { return TimeSpan(static_cast<uint64>(hours)        * 1000000000 * 60 * 60); }
Example #27
0
 TimeSpan TimeSpan::Days(int days)                    { return TimeSpan(static_cast<uint64>(days)            * 1000000000 * 60 * 60 * 24); }
void StatisticsWriterHtml::Write(const Statistics *stats)
{
	*stream() <<
	"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n"
	"\"http://www.w3.org/TR/html4/loose.dtd\">\n"
	"<html>\n"
	"<head>\n"
	"	<title>" << "Profile of '" << script_name() << "'</title>\n"
	"</head>\n"
	"<body>\n";

	*stream() <<
	"	<style type=\"text/css\">\n"
	"	table.meta {\n"
	"		width: auto;\n"
	"	}\n"
	"	table {\n"
	"		border-spacing:0;\n"
	"		border-collapse: collapse;\n"
	"	}\n"
	"	table, th, td {\n"
	"		border: 1px solid #cccccc;\n"
	"	}\n"
	"	td {\n"
	"		font-family: Consolas, \"Courier New\", \"Monospace\";\n"
	"		border: solid 5x transparent;\n"
	"	}\n"
	"	th {\n"
	"		background-color: #cccccc;\n"
	"	}\n"
	"	</style>\n"
	"	<table class=\"meta\" border=\"1\">\n"
	"		<thead>\n"
	"			<tr>\n"
	"				<th>Name</th>\n"
	"				<th>Value</th>\n"
	"			</tr>\n"
	"		</thead>\n"
	"		<tbody>\n";

	if (print_date()) {
		*stream() <<
		"			<tr>\n"
		"				<td>Date</td>\n"
		"				<td>" << CTime() << "</td>\n"
		"			</tr>\n";
	}

	if (print_run_time()) {
		*stream() <<
		"			<tr>\n"
		"				<td>Duration</td>\n"
		"				<td>" << TimeSpan(stats->GetTotalRunTime()) << "</td>\n"
		"			</tr>\n";
	}

	*stream() <<
	"		</tbody>\n"
	"	</table>\n"
	"	<br/>"
	"	<style type=\"text/css\">\n"
	"	tr:nth-child(odd) {\n"
	"		background-color: #eeeeee;\n"
	"	}\n"
	"	</style>\n"
	"	<table id=\"func-stats\" class=\"tablesorter\" border=\"1\" width=\"100%\">\n"
	"		<thead>\n"
	"			<tr>\n"
	"				<th>Type</th>\n"
	"				<th>Name</th>\n"
	"				<th>Calls</th>\n"
	"				<th colspan=\"2\">Self Time</th>\n"
	"				<th colspan=\"2\">Total Time</th>\n"
	"				<th>Best time</th>\n"
	"				<th>Worst time</th>\n"
	"				<th>Average time</th>\n"
	"			</tr>\n"
	"		</thead>\n"
	"		<tbody>\n"
	;

	std::vector<FunctionStatistics*> all_fn_stats;
	stats->GetStatistics(all_fn_stats);

	Nanoseconds time_all;
	for (std::vector<FunctionStatistics*>::const_iterator iterator = all_fn_stats.begin();
			iterator != all_fn_stats.end(); ++iterator)
	{
		const FunctionStatistics *fn_stats = *iterator;
		time_all += fn_stats->total_time() - fn_stats->child_time(); 
	};

	Nanoseconds total_time_all;
	for (std::vector<FunctionStatistics*>::const_iterator iterator = all_fn_stats.begin();
			iterator != all_fn_stats.end(); ++iterator)
	{
		const FunctionStatistics *fn_stats = *iterator;
		total_time_all += fn_stats->total_time(); 
	};

	for (std::vector<FunctionStatistics*>::const_iterator iterator = all_fn_stats.begin();
			iterator != all_fn_stats.end(); ++iterator)
	{
		const FunctionStatistics *fn_stats = *iterator;

		double self_time_sec = Seconds(fn_stats->GetSelfTime()).count();
		double self_time_percent = fn_stats->GetSelfTime().count() * 100 / time_all.count();

		double total_time_sec = Seconds(fn_stats->total_time()).count();
		double total_time_percent = fn_stats->total_time().count() * 100 / total_time_all.count();

		double best_time_sec = Seconds(fn_stats->best_time()).count();
		double worst_time_sec = Seconds(fn_stats->worst_time()).count();
		double average_time_sec = Seconds(fn_stats->average_time()).count();

		*stream()
		<< "		<tr>\n"
		<< "			<td>" << fn_stats->function()->type() << "</td>\n"
		<< "			<td>" << fn_stats->function()->name() << "</td>\n"
		<< "			<td>" << fn_stats->num_calls() << "</td>\n"
		<< "			<td>" << std::fixed << std::setprecision(2) << self_time_percent << "%</td>\n"
		<< "			<td>" << std::fixed << std::setprecision(3) << self_time_sec << "s</td>\n"
		<< "			<td>" << std::fixed << std::setprecision(2) << total_time_percent << "%</td>\n"
		<< "			<td>" << std::fixed << std::setprecision(3) << total_time_sec << "s</td>\n"
		<< "			<td>" << std::fixed << std::setprecision(3) << best_time_sec << "s</td>\n"
		<< "			<td>" << std::fixed << std::setprecision(3) << worst_time_sec << "s</td>\n"
		<< "			<td>" << std::fixed << std::setprecision(3) << average_time_sec << "s</td>\n"
		<< "			</td>\n"
		<< "		</tr>\n";
	};

	*stream() <<
	"		</tbody>\n"
	"	</table>\n"
	;

	*stream() <<
	"	<script type=\"text/javascript\"\n"
	"		src=\"http://code.jquery.com/jquery-latest.min.js\"></script>\n"
	"	<script type=\"text/javascript\"\n"
	"		src=\"http://tablesorter.com/__jquery.tablesorter.min.js\"></script>\n"
	"	<script type=\"text/javascript\">\n"
	"	$(document).ready(function() {\n"
	"		$(\"#func-stats\").tablesorter();\n"
	"	});\n"
	"	</script>\n"
	"	<br/>\n"
	"	<footer>\n"
	;

	*stream() <<
	"	</footer>\n"
	"</body>\n"
	"</html>\n"
	;
}
TimeSpan TimeSpan::operator-(const TimeSpan& right) {
  return TimeSpan(_seconds-right._seconds);
}
Example #30
0
 TimeSpan TimeSpan::MilliSeconds(uint64 milliseconds){ return TimeSpan(static_cast<uint64>(milliseconds) * 1000000); }