当前位置: 首页>>代码示例>>C++>>正文


C++ DTime类代码示例

本文整理汇总了C++中DTime的典型用法代码示例。如果您正苦于以下问题:C++ DTime类的具体用法?C++ DTime怎么用?C++ DTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: draw

	/**
	 *  \brief Draw, Call back from the GLMoblet.
	 */
	void draw()
	{
		mDTime.tick(); // update delta time ticker. our fps timer (resets for every tick call)
		MoGraph::Scene &scene = mGraph->getScene();	// get scene information
		const int iGridZ = scene.getGridZ(); // need to be able to read the grid size
		const int iGridX = scene.getGridX();
		const int sz = iGridX * iGridZ;

		mGraph->setValues(mTables,sz); // set the value array to the Graph to read from
		mGraph->setColors(mColors,sz); // set the color array to the Graph to read from

		mGraph->draw(); // Draw the whole graph system


		// DRAW ADDITIONAL TEXT ON SCREEN (Orthogonal projections)
		//---------------------------------------------------------------------
		glm::vec4 col(1.0f,1.0f,1.0f,1.0f);	// White color
		glm::vec3 pos(0.0f,0.0f,10.0f); // set screen position upper left corner 0,0.. note need z depth value for order.
		float sy = (0.6f*(float)scene.getWidth())/320.0f; // scale size regardless to resolution our reference resolution is 320..
		mText.setScale(sy,sy);

		char buf[64]; // create text string
		sprintf ( buf, "FPS=%.2f ms=%d",mDTime.currentFps(),mDTime.getElapsed());
		mText.drawText(buf,pos,col); // call drawText
	}
开发者ID:Felard,项目名称:MoSync,代码行数:28,代码来源:main.cpp

示例2: totalTimeCurrentDay

DTime Task::totalTimeCurrentDay() const {
    DateTime today = DateTime::today();
    DateTime tomorrow = today.addDays(1);
    DTime totalTime;
    if (childCount() == 0) {
        for (vector<TaskLog*>::iterator iterLog = _logs->begin(); iterLog != _logs->end(); iterLog++) {
            TaskLog* log = *iterLog;
            if (*log->start >= today) {
                if (*log->end < tomorrow) {
                    totalTime.add((*log->end) - (*log->start));
                } else {
                    totalTime.add((*log->end) - tomorrow);
                }
            }
        }
    } else {
        vector<Task*> subtasks = children();
        for (vector<Task*>::iterator iter = subtasks.begin(); iter != subtasks.end(); iter++) {
            Task* sub = *iter;
            totalTime.add(sub->totalTimeCurrentDay());
        }
    }
    return totalTime;

}
开发者ID:crossleyjuan,项目名称:djon,代码行数:25,代码来源:task.cpp

示例3: producer

void* producer(void* arg) {
	NetworkOutputStream* nos = new NetworkOutputStream();
	int socket = nos->open("localhost", _port);

	printf("Producer started\n");
	Logger* log = getLogger(NULL);
	log->info("Producer starter");
	log->startTimeRecord();
	if (socket > 0) {
		NetworkInputStream* nis = new NetworkInputStream(socket);

		std::auto_ptr<CommandWriter> writer(new CommandWriter(nos));

		for (int x = 0; x < MAX_INSERT; x++) {
			std::auto_ptr<InsertCommand> cmd(new InsertCommand());

			BSONObj* obj = new BSONObj();
			std::auto_ptr<std::string> guid(uuid());
			obj->add("_id", guid->c_str());
			char* temp = (char*)malloc(2000);
			memset(temp, 0, 2000);
			memset(temp, 'a', 1999);
			int len = strlen(temp);
			obj->add("content", temp);
			free(temp);
			cmd->setBSON(obj);
			std::string db("mydb");
			cmd->setDB(db);
			std::string ns("myns");
			cmd->setNameSpace(ns);
			cmd->setOptions(new BSONObj());
			writer->writeCommand(cmd.get());

			int result = nis->readInt();

			EXPECT_EQ(result, 1);
			if (result != 1) {
				break;
			}
		}
		nis->close();
	} else {
		printf("Socket is 0");
	}
	log->info("Producer end");
	log->stopTimeRecord();

	DTime time = log->recordedTime();
	if (time.totalSecs() > 0) {
		log->info("Producer time: %d secs. Operations per sec: %d", time.totalSecs(), MAX_INSERT / time.totalSecs());
	} else {
		EXPECT_TRUE(false) << "Something was wrong network could not execute " << MAX_INSERT << " in 0 secs.";
	}
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:54,代码来源:main.cpp

示例4: totalTime

DTime Task::totalTime() const {
    DTime result;
    for (vector<TaskLog*>::iterator iterLog = _logs->begin(); iterLog != _logs->end(); iterLog++) {
        TaskLog* log = *iterLog;
        result.add((*log->end) - (*log->start));
    }
    vector<Task*> subtasks = children();
    for (vector<Task*>::iterator iter = subtasks.begin(); iter != subtasks.end(); iter++) {
        Task* sub = *iter;
        result.add(sub->totalTime());
    }
    return result;
}
开发者ID:crossleyjuan,项目名称:djon,代码行数:13,代码来源:task.cpp

示例5: TEST

TEST(testUtil, testLogger) {
	// Test timer
	//
	Logger* log = getLogger(NULL);
	log->startTimeRecord();
	Thread::sleep(3000);
	log->stopTimeRecord();

	DTime time = log->recordedTime();

	long secs = time.totalSecs();

	EXPECT_TRUE(secs > 2);
	EXPECT_TRUE(secs < 4);
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:15,代码来源:main.cpp

示例6: assert

DatabaseQuery* Draw::GetDataToFetch() {
	const DTime& start_time = m_index.GetStartTime();
	assert(start_time.IsValid());

	PeriodType period = start_time.GetPeriod();

	int d = m_values.m_view.Start();

	DatabaseQuery* q = NULL;

	if (m_draw_info == NULL)
		return q;

	if (GetEnable() == false)
		return q;

	bool no_max_probes = !m_draw_info->IsValid() || m_draw_info->GetParam()->GetIPKParam()->GetFormulaType() == TParam::LUA_AV;
	for (size_t i = 0; i < m_values.len(); ++i) {
		ValueInfo &v = m_values.Get(i);

		if (v.state != ValueInfo::EMPTY) 
			continue;
		
		DTime pt = GetDTimeOfIndex(i - d);
		if (period == PERIOD_T_DAY)
			v.max_probes = 1;
		else if (no_max_probes)
			v.max_probes = 0;
		else {
			DTime ptn = pt + m_index.GetDateRes() + m_index.GetTimeRes();
			v.max_probes = (ptn.GetTime() - pt.GetTime()).GetMinutes() / 10;
		}

		v.state = ValueInfo::PENDING;
		
		if (q == NULL)
			q = CreateDataQuery(m_draw_info, period, m_draw_no);
		AddTimeToDataQuery(q, pt.GetTime().GetTicks());
	}

	return q;
}
开发者ID:cyclefusion,项目名称:szarp,代码行数:42,代码来源:draw.cpp

示例7: draw

	/**
	 *  \brief Draw, Call back from the GLMoblet.
	 */
	void draw()
	{
		mDTime.tick(); // update delta time ticker. our fps timer (resets for every tick call)
		MoGraph::Scene &scene = mGraph->getScene();	// get scene information
		const int iGridZ = scene.getGridZ(); // need to be able to read the grid size
		const int iGridX = scene.getGridX();
		const int sz = iGridX * iGridZ;
		float dt = static_cast<float>(mDTime.getElapsed())*0.001f; // calculate a delta time factor for omega
		mOmega += dt; // accumulate the omega used for sin/cos func

		if (mOmega > M_PI*2.0f)	// for high precision make sure omega 0..2*PI
			mOmega -= M_PI*2.0f; // wrapping a x value is also faster not to use large values in sin(x).

		const float f = 2.5f/255.0f; // prepare for a scale value of result being max 2.5f
		for(int j=0; j<iGridZ; j++)	// Build the data arrays for colors and for tables.
		{
			const float jcos = 2.0f + cos(j*0.3f+mOmega); // calculate the Depth Wave with cos
			for(int i=0; i<iGridX; i++)
			{
				const int id 	= j*iGridX+i;
				Color *c 		= (Color *)&mLogoH.getData()[id];
				mTables[id] 	= (float)c->r * f + (sin(i*0.3f+mOmega) + jcos); // generate a sine wave and add depth wave
			}
		}

		mGraph->setValues(mTables,sz); // set the value array to the Graph to read from
		mGraph->setColors(mColors,sz); // set the color array to the Graph to read from

		mGraph->draw();	// Draw the whole graph system


		// DRAW ADDITIONAL TEXT ON SCREEN (Orthogonal projections)
		//---------------------------------------------------------------------
		glm::vec4 col(1.0f,1.0f,1.0f,1.0f);	// White color
		glm::vec3 pos(0.0f,0.0f,10.0f);	// set screen position upper left corner 0,0.. note need z depth value for order.
		float sy = (0.6f*(float)scene.getWidth())/320.0f; // scale size regardless to resolution our reference resolution is 320..
		mText.setScale(sy,sy);

		char buf[64]; // create text string
		sprintf ( buf, "FPS=%.2f ms=%d",mDTime.currentFps(),mDTime.getElapsed());
		mText.drawText(buf,pos,col); // call drawText
	}
开发者ID:Vallenain,项目名称:MoSync,代码行数:45,代码来源:main.cpp

示例8: switch

DTime TimeIndex::AdjustToPeriodSpan(const DTime &time) const {
	wxDateTime dt = time.GetTime();

	if (m_number_of_values == default_units_count[time.GetPeriod()] * PeriodMult[time.GetPeriod()]) {
		switch (time.GetPeriod()) {
			case PERIOD_T_DECADE :
			case PERIOD_T_YEAR :
				dt.SetMonth(wxDateTime::Jan);
			case PERIOD_T_MONTH :
				dt.SetDay(1);
				dt.SetHour(0);
				break;
			case PERIOD_T_WEEK:
			case PERIOD_T_SEASON :
				dt.SetToWeekDayInSameWeek(wxDateTime::Mon);
			case PERIOD_T_DAY :
				dt.SetHour(0);
				dt.SetMinute(0);
				break;
			case PERIOD_T_30MINUTE :
				dt.SetMinute(dt.GetMinute() / 30 * 30);
				dt.SetSecond(0);
				break;
			case PERIOD_T_5MINUTE :
				dt.SetMinute(dt.GetMinute() / 3 * 3);
				dt.SetSecond(0);
				break;
			case PERIOD_T_MINUTE :
			case PERIOD_T_30SEC :
				dt.SetSecond(dt.GetSecond() / 30 * 30);
				break;
			case PERIOD_T_OTHER:
			case PERIOD_T_LAST:
				assert(false);
		}
		return DTime(time.GetPeriod(), dt);
	} else {
		DTime ret(time);
		return ret.AdjustToPeriodStart();
	}
}
开发者ID:Strongc,项目名称:szarp,代码行数:41,代码来源:drawtime.cpp

示例9: totalTimeCurrentWeek

DTime Task::totalTimeCurrentWeek() const {
    DateTime startDayWeek = DateTime::startDayOfWeek();
    DateTime startDayOfNextWeek = DateTime::startDayOfNextWeek();
    DTime totalTime;
    if (childCount() == 0) {
        for (vector<TaskLog*>::iterator iterLog = _logs->begin(); iterLog != _logs->end(); iterLog++) {
            TaskLog* log = *iterLog;
            if ((*(log->start) >= startDayWeek) &&
                (*(log->end) < startDayOfNextWeek)) {
                totalTime.add((*log->end) - (*log->start));
            }
        }
    } else {
        vector<Task*> subtasks = children();
        for (vector<Task*>::iterator iter = subtasks.begin(); iter != subtasks.end(); iter++) {
            Task* sub = *iter;
            totalTime.add(sub->totalTimeCurrentWeek());
        }
    }
    return totalTime;
}
开发者ID:crossleyjuan,项目名称:djon,代码行数:21,代码来源:task.cpp

示例10: testFind

		void testFind(int port, int top = 10000000) {
			DjondbConnection* conn = DjondbConnectionManager::getConnection("localhost", port);

			if (!conn->open()) {
				cout << "Not connected" << endl;
				exit(0);
			}

			Logger* log = getLogger(NULL);

			log->startTimeRecord();
			log->info("Testing find performance over: %d finds.", top);
			for (int x = 0; x < top; x++) {
				BSONArrayObj* arr = conn->executeQuery("select top 1 * from db:testperformance");
				if (arr->length() == 0) {
					log->info("Error an id was not found");
					exit(1);
				}
				delete arr;
			}
			log->stopTimeRecord();

			DTime time = log->recordedTime();

			cout << "Total find secs: " << time.totalSecs() << endl;
			if (time.totalSecs() > 0) {
				log->info("Found %d: throughtput: %d.", top, (top / time.totalSecs()));
			} else {
				log->info("Found :%d, throughtput too high to be measured", top);
			}
			if ((time.totalSecs() > 0) && ((top / time.totalSecs()) < 16000))  {
				log->info("Performance is not good enough");
			}
		}
开发者ID:FikiHafana,项目名称:djondb,代码行数:34,代码来源:testperformance.cpp

示例11: drawTime

void TimeScene::drawTime(DateTime currentDay, DTime time, QModelIndex index, int groupLevel) {
    QSize size = sizeHint(index);
    int bordermargin = (size.height() * .1) / 2;

    QBrush b;
    QPen pen(QColor(0, 0, 150));
    QBrush textBrush;
    if (groupLevel == 2) {
        b = QBrush(Qt::white);
        pen = QPen(QColor(0, 0, 150));
        textBrush = QBrush(Qt::darkBlue);
    }
    if (groupLevel == 1) {
        b = QBrush(Qt::lightGray);
        pen = QPen(QColor(0, 0, 50));
        textBrush = QBrush(Qt::blue);
    }
    if (groupLevel == 0) {
        b = QBrush(Qt::darkGray);
        pen = QPen(QColor(100, 100, 200));
        textBrush = QBrush(Qt::white);
    }

    int daysToStart = _startDate.daysTo(currentDay);
    int x1 = daysToStart * _dayWidth;
    int y1 = _currentY + bordermargin;
    int x2 = x1 + _dayWidth;
    int y2 = _currentY + size.height() - bordermargin;

//    QGraphicsRectItem* item = this->addRect(x1, y1, (x2 - x1), (y2 - y1), pen, b);
    QRect rect(x1, y1, (x2 - x1), (y2 - y1));
    GraphicsRectItem* item = new GraphicsRectItem(rect, index);
    this->addItem(item);
    item->setPen(pen);
    item->setBrush(b);
    item->setZValue(1);
    item->setAcceptHoverEvents(true);

    connect(item, SIGNAL(itemHoverEnter(QModelIndex)), this, SLOT(receiveItemHoverEnter(QModelIndex)));
    connect(item, SIGNAL(itemHoverLeave(QModelIndex)), this, SLOT(receiveItemHoverLeave(QModelIndex)));

    QFont font("Arial", 8);

    font.setBold((groupLevel <= 1));
    font.setItalic((groupLevel == 0));

    QGraphicsSimpleTextItem* text = addSimpleText(time.toQString(), font);
    text->setBrush(textBrush);
    text->setPos(x1 + 2, y1 + 1);
    text->setVisible(true);
    text->setZValue(1);
}
开发者ID:crossleyjuan,项目名称:djon,代码行数:52,代码来源:timescene.cpp

示例12: testTimes

		void testTimes()
		{
			// Testing diff
			DTime t(15, 40, 0);
			DTime t2(16, 20, 0);
			DTime res = t2 - t;

			TEST_ASSERT((res.hour() == 0) && (res.minutes() == 40) && (res.seconds() == 0));

			res = t2 - 200;
			TEST_ASSERT((res.hour() == 16) && (res.minutes() == 16) && (res.seconds() == 40));
			// teting add
		}
开发者ID:neoecos,项目名称:djondb,代码行数:13,代码来源:main.cpp

示例13: wxDynamicCast

void XYDialog::OnDateChange(wxCommandEvent &event) {
	wxButton *button;
	DTime *time;

	if (event.GetId() == XY_START_TIME) {
		button = wxDynamicCast(FindWindow(XY_START_TIME), wxButton);
		time = &m_start_time;
	} else {
		button = wxDynamicCast(FindWindow(XY_END_TIME), wxButton);
		time = &m_end_time;
	}

	DateChooserWidget *dcw = 
		new DateChooserWidget(
				this,
				_("Select date"),
				1,
				-1,
				-1,
				1
		);

	wxDateTime wxtime = time->GetTime();
	
	bool ret = dcw->GetDate(wxtime);
	dcw->Destroy();

	if (ret == false)
		return;

	*time = DTime(m_period, wxtime);
	time->AdjustToPeriod();

	button->SetLabel(FormatTime(time->GetTime(), m_period));

}
开发者ID:cyclefusion,项目名称:szarp,代码行数:36,代码来源:xydiag.cpp

示例14: GetIndex

int TimeIndex::GetIndex(const DTime& time, int *dist) const {
	int i, d;
	if (!m_time.IsValid() || !time.IsValid()) {
		i = -1, d = 0;
	} else {
		i = d = m_time.GetDistance(time);

		if (d < 0 || d >= (int)m_number_of_values)
			i = -1;
	}
	if (dist)
		*dist = d;

	return i;
}
开发者ID:Strongc,项目名称:szarp,代码行数:15,代码来源:drawtime.cpp

示例15: testCommand

		void testCommand(int port, int top = 10000000) {
			DjondbConnection* conn = DjondbConnectionManager::getConnection("localhost", port);

			if (!conn->open()) {
				cout << "Not connected" << endl;
				exit(0);
			}

			Logger* log = getLogger(NULL);

			log->startTimeRecord();
			log->info("Testing command performance over: %d executions.", top);
			for (int x = 0; x < top; x++) {
				std::vector<std::string>* dbs = conn->dbs();
				if (dbs == NULL) {
					log->info("Test command failed and returned NULL");
					exit(1);
				}
				if (dbs->size() == 0) {
					log->info("Test command failed and returned 0 elements");
					exit(1);
				}
				delete dbs;
			}
			log->stopTimeRecord();

			DTime time = log->recordedTime();

			cout << "Total secs: " << time.totalSecs() << endl;
			if (time.totalSecs() > 0) {
				log->info("Executed %d: throughtput: %d.", top, (top / time.totalSecs()));
			} else {
				log->info("Executed %d, throughtput too high to be measured", top);
			}
			if ((time.totalSecs() > 0) && ((top / time.totalSecs()) < 5000))  {
				log->info("Performance is not good enough");
			}
		}
开发者ID:FikiHafana,项目名称:djondb,代码行数:38,代码来源:testperformance.cpp


注:本文中的DTime类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。