`get timestamp` C++ Examples
38 C++ code examples are found related to "get timestamp".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: cache.cpp From CommandTrayHost with MIT License | 6 votes |
bool get_filetime(PCWSTR const filename, FILETIME& file_write_timestamp) { if (TRUE != PathFileExists(filename)) { msg_prompt(filename, L"File not exist"); return false; } HANDLE json_hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (!json_hFile)return false; bool ret = true; if (!GetFileTime(json_hFile, NULL, NULL, &file_write_timestamp))ret = false; CloseHandle(json_hFile); return ret; }
Example 2
Source File: InnoLogger.cpp From InnocenceEngine with GNU General Public License v3.0 | 6 votes |
inline std::ostream& GetTimestamp(std::ostream &s) { auto l_timeData = InnoTimer::GetCurrentTime(8); s << "[" << l_timeData.Year << "-" << l_timeData.Month << "-" << l_timeData.Day << "-" << l_timeData.Hour << "-" << l_timeData.Minute << "-" << l_timeData.Second << "-" << l_timeData.Millisecond << "]"; return s; }
Example 3
Source File: opencl.cpp From CNN-Acceleration with GNU General Public License v3.0 | 6 votes |
double getCurrentTimestamp() { #ifdef _WIN32 // Windows // Use the high-resolution performance counter. static LARGE_INTEGER ticks_per_second = {}; if(ticks_per_second.QuadPart == 0) { // First call - get the frequency. QueryPerformanceFrequency(&ticks_per_second); } LARGE_INTEGER counter; QueryPerformanceCounter(&counter); double seconds = double(counter.QuadPart) / double(ticks_per_second.QuadPart); return seconds; #else // Linux timespec a; clock_gettime(CLOCK_MONOTONIC, &a); return (double(a.tv_nsec) * 1.0e-9) + double(a.tv_sec); #endif }
Example 4
Source File: TransactionNormal.cpp From Elastos.ELA.SPV.Cpp with MIT License | 6 votes |
time_t TransactionNormal::GetEarliestTxnTimestamp() const { time_t timestamp = 0; std::string sql; sql = "SELECT " + _timestamp + " FROM " + _tableName + " ORDER BY " + _timestamp + " ASC LIMIT 1;"; sqlite3_stmt *stmt = NULL; if (!_sqlite->Prepare(sql, &stmt, nullptr)) { Log::error("prepare sql: {}", sql); return timestamp; } while (SQLITE_ROW == _sqlite->Step(stmt)) { timestamp = _sqlite->ColumnInt(stmt, 0); } if (!_sqlite->Finalize(stmt)) { Log::error("Tx get all finalize"); return timestamp; } return timestamp; }
Example 5
Source File: utils_func.cpp From babel-trader with MIT License | 6 votes |
int64_t XTPGetTimestamp(int64_t xtp_ts) { struct tm time_info = { 0 }; int64_t year = xtp_ts / 10000000000000; int64_t month = (xtp_ts / 100000000000) % 100; int64_t day = (xtp_ts / 1000000000) % 100; int64_t hour = (xtp_ts / 10000000) % 100; int64_t minute = (xtp_ts / 100000) % 100; int64_t sec = (xtp_ts / 1000) % 100; int64_t mill = xtp_ts % 1000; time_info.tm_year = year - 1900; time_info.tm_mon = month - 1; time_info.tm_mday = day; time_info.tm_hour = hour; time_info.tm_min = minute; time_info.tm_sec = sec; time_t utc_sec = mktime(&time_info); return (int64_t)utc_sec * 1000 + mill; }
Example 6
Source File: system_utils.cpp From spqrel_navigation with MIT License | 6 votes |
std::string getTimestamp() { //ds obtain current time as count timeval time_value; gettimeofday(&time_value, 0); //ds compute milliseconds const int milliseconds = time_value.tv_usec/1000; //ds obtain structured time information (hours, minutes, seconds) struct tm* time_info = localtime(&time_value.tv_sec); //ds stream to formatted string char buffer[13]; std::snprintf(buffer, 13, "%02i:%02i:%02i.%03i", time_info->tm_hour, time_info->tm_min, time_info->tm_sec, milliseconds); return std::string(buffer); }
Example 7
Source File: timeutil.cpp From rocksplicator with Apache License 2.0 | 6 votes |
int64_t GetCurrentTimestamp(const TimeUnit type) { time_point<hclock> t0 = hclock::now(); switch (type) { case kHour: return duration_cast<hours>(t0.time_since_epoch()).count(); case kMinute: return duration_cast<minutes>(t0.time_since_epoch()).count(); case kSecond: return duration_cast<seconds>(t0.time_since_epoch()).count(); case kMillisecond: return duration_cast<milliseconds>(t0.time_since_epoch()).count(); case kMicrosecond: return duration_cast<microseconds>(t0.time_since_epoch()).count(); case kNanosecond: return duration_cast<nanoseconds>(t0.time_since_epoch()).count(); default: // By default return millisecond results return duration_cast<milliseconds>(t0.time_since_epoch()).count(); } }
Example 8
Source File: test_vertex_time_queries_test.cc From maplab with Apache License 2.0 | 6 votes |
pose_graph::VertexId getGroundTruthVertexIdClosestInTime( const int64_t query_timestamp_nanoseconds, const pose_graph::VertexIdList& vertex_ids, const vi_map::VIMap::Ptr& map) { CHECK(map); pose_graph::VertexId closest_vertex_id; closest_vertex_id.setInvalid(); CHECK(!vertex_ids.empty()); int64_t closest_timestamp_difference = std::numeric_limits<int64_t>::max(); for (const pose_graph::VertexId& vertex_id : vertex_ids) { CHECK(vertex_id.isValid()); const int64_t timestamp_nanoseconds = map->getVertex(vertex_id).getMinTimestampNanoseconds(); const int64_t timestamp_difference_nanoseconds = std::abs(timestamp_nanoseconds - query_timestamp_nanoseconds); if (timestamp_difference_nanoseconds < closest_timestamp_difference) { closest_timestamp_difference = timestamp_difference_nanoseconds; closest_vertex_id = vertex_id; } } CHECK(closest_vertex_id.isValid()); return closest_vertex_id; }
Example 9
Source File: timestamp.cpp From duckdb with MIT License | 5 votes |
timestamp_t Timestamp::GetCurrentTimestamp() { auto in_time_t = std::time(nullptr); auto utc = std::gmtime(&in_time_t); // tm_year[0...] considers the amount of years since 1900 and tm_mon considers the amount of months since january // tm_mon[0-11] auto date = Date::FromDate(utc->tm_year + START_YEAR, utc->tm_mon + 1, utc->tm_mday); auto time = Time::FromTime(utc->tm_hour, utc->tm_min, utc->tm_sec); return Timestamp::FromDatetime(date, time); }
Example 10
Source File: physicalsocketserver.cc From anyRTC-RTMP-OpenSource with GNU General Public License v3.0 | 5 votes |
int64_t GetSocketRecvTimestamp(int socket) { struct timeval tv_ioctl; int ret = ioctl(socket, SIOCGSTAMP, &tv_ioctl); if (ret != 0) return -1; int64_t timestamp = rtc::kNumMicrosecsPerSec * static_cast<int64_t>(tv_ioctl.tv_sec) + static_cast<int64_t>(tv_ioctl.tv_usec); return timestamp; }
Example 11
Source File: Utils.cpp From cron-job.org with GNU General Public License v2.0 | 5 votes |
uint64_t Utils::getTimestampMS() { uint64_t result = 0; struct timeval tv; if(gettimeofday(&tv, nullptr) == 0) result = (uint64_t)tv.tv_sec * 1000 + (uint64_t)tv.tv_usec / 1000; return(result); }
Example 12
Source File: fdbmonitor.cpp From foundationdb with Apache License 2.0 | 5 votes |
double get_cur_timestamp() { struct tm tm_info; struct timeval tv; gettimeofday(&tv, NULL); localtime_r(&tv.tv_sec, &tm_info); return tv.tv_sec + 1e-6*tv.tv_usec; }
Example 13
Source File: tempname.cpp From keyvi with Apache License 2.0 | 5 votes |
std::string get_timestamp() { std::stringstream ss; ss << boost::posix_time::second_clock::local_time(); std::string name = ss.str(); std::replace(name.begin(), name.end(), ':', '-'); std::replace(name.begin(), name.end(), ' ', '_'); return name; }
Example 14
Source File: ESP32TimeHelper.cpp From ESP32-Mail-Client with MIT License | 5 votes |
time_t ESP32TimeHelper::getTimestamp(int year, int mon, int date, int hour, int mins, int sec) { struct tm timeinfo; timeinfo.tm_year = year - 1900; timeinfo.tm_mon = mon - 1; timeinfo.tm_mday = date; timeinfo.tm_hour = hour; timeinfo.tm_min = mins; timeinfo.tm_sec = sec; time_t ts = mktime(&timeinfo); return ts; }
Example 15
Source File: KinectToVR.cpp From KinectToVR with GNU General Public License v3.0 | 5 votes |
std::string log_get_timestamp_prefix() { // From PSMoveService ServerLog.cpp auto now = std::chrono::system_clock::now(); auto seconds = std::chrono::time_point_cast<std::chrono::seconds>(now); auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(now - seconds); time_t in_time_t = std::chrono::system_clock::to_time_t(now); std::stringstream ss; ss << "[" << std::put_time(std::localtime(&in_time_t), "%Y-%m-%d %H:%M:%S") << "." << milliseconds.count() << "]: "; return ss.str(); }
Example 16
Source File: monotonic_clock.cpp From hawktracer with MIT License | 5 votes |
HT_TimestampNs ht_monotonic_clock_get_timestamp(void) { #ifdef HT_MONOTONIC_CLOCK_IMPL_CPP11 return static_cast<HT_TimestampNs>(std::chrono::steady_clock::now().time_since_epoch().count()); #elif defined(HT_MONOTONIC_CLOCK_IMPL_POSIX) struct timespec time; // Note: Do we need to link to -lrt to define clock_gettime? clock_gettime(CLOCK_MONOTONIC, &time); return (HT_TimestampNs) (HT_DUR_S(time.tv_sec) + time.tv_nsec); #elif defined(HT_MONOTONIC_CLOCK_IMPL_APPLE) /* TODO: use mach_absolute_time() instead? */ clock_serv_t cclock; mach_timespec_t time; host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock); clock_get_time(cclock, &time); mach_port_deallocate(mach_task_self(), cclock); return (HT_TimestampNs) (HT_DUR_S(time.tv_sec) + time.tv_nsec); #elif defined(HT_MONOTONIC_CLOCK_IMPL_WIN32) LARGE_INTEGER li; QueryPerformanceCounter(&li); return (li.QuadPart) * 1000000000 / _ht_msvc_frequency; #else # error "Monotonic clock provider has not been found. Define HT_MONOTONIC_CLOCK_IMPL_CUSTOM" \ "and provide custom implementation of ht_monotonic_clock_get_timestamp() function" #endif }
Example 17
Source File: utils_func.cpp From babel-trader with MIT License | 5 votes |
int64_t CTPGetTimestamp(const char *str_date, const char *str_time, int millisec) { struct tm time_info = { 0 }; int date = atoi(str_date); time_info.tm_year = date / 10000 - 1900; time_info.tm_mon = (date % 10000) / 100 - 1; time_info.tm_mday = date % 100; if (strlen(str_time) == 8) { char buf[16] = { 0 }; strncpy(buf, str_time, sizeof(buf)); buf[2] = '\0'; buf[5] = '\0'; time_info.tm_hour = atoi(&buf[0]); time_info.tm_min = atoi(&buf[3]); time_info.tm_sec = atoi(&buf[6]); } time_t utc_sec = mktime(&time_info); return (int64_t)utc_sec * 1000 + (int64_t)millisec; }
Example 18
Source File: FolderUtils.cpp From RobustGNSS with MIT License | 5 votes |
string getTimestamp() { auto now = std::time(nullptr); char buf[sizeof("YYYY-MM-DD HH:MM:SS")]; string timeDateStr = std::string(buf,buf + std::strftime(buf,sizeof(buf),"%F %T",std::gmtime(&now))); replace_first(timeDateStr, " ", "_"); replace_all(timeDateStr, ":","-"); return timeDateStr; }
Example 19
Source File: dataset.cpp From openthread with BSD 3-Clause "New" or "Revised" License | 5 votes |
const Timestamp *Dataset::GetTimestamp(void) const { const Timestamp *timestamp = nullptr; if (mType == kActive) { const ActiveTimestampTlv *tlv = GetTlv<ActiveTimestampTlv>(); VerifyOrExit(tlv != nullptr, OT_NOOP); timestamp = static_cast<const Timestamp *>(tlv); } else {
Example 20
Source File: RTCPSenderReport.cpp From media-server with GNU General Public License v2.0 | 5 votes |
QWORD RTCPSenderReport::GetTimestamp() const { //Convert to epcoh JAN_1970 QWORD ts = ntpSec - 2208988800UL; //convert to microseconds ts *=1E6; //Add fraction ts += ntpFrac/4294.967296; //Return it return ts; }
Example 21
Source File: viewerplaybacktimer.cpp From olive with GNU General Public License v3.0 | 5 votes |
int64_t ViewerPlaybackTimer::GetTimestampNow() const { int64_t real_time = QDateTime::currentMSecsSinceEpoch() - start_msec_; int64_t frames_since_start = qRound(static_cast<double>(real_time) / (timebase_ * 1000)); return start_timestamp_ + frames_since_start * playback_speed_; }
Example 22
Source File: graph_tracer.cc From mediapipe with Apache License 2.0 | 5 votes |
Timestamp GraphTracer::GetOutputTimestamp(const CalculatorContext* context) { for (const OutputStreamShard& out_stream : context->Outputs()) { for (const Packet& packet : *out_stream.OutputQueue()) { if (packet.Timestamp() != Timestamp::Unset()) { return packet.Timestamp(); } } } return Timestamp(); }
Example 23
Source File: logger.cc From NativePlayer with MIT License | 5 votes |
double GetTimestamp() { using std::chrono::steady_clock; using std::chrono::duration_cast; using std::chrono::duration; static auto st_begin = steady_clock::now(); auto now = steady_clock::now(); return duration<double>{now - st_begin}.count(); }
Example 24
Source File: packet_trace.cpp From etwrealtime with Apache License 2.0 | 5 votes |
void PacketTraceSessionImpl::GetTimestamp(LARGE_INTEGER ts, uint32_t &tv_sec, uint32_t &tv_ns) { // removes the diff between 1970 and 1601 uint64_t QuadPart = ts.QuadPart - gTimestampAdjust.QuadPart; tv_sec = (uint32_t)(QuadPart / 10000000); tv_ns = (uint32_t)(QuadPart % 10000000)*100; }
Example 25
Source File: volumesequenceutils.cpp From inviwo with BSD 2-Clause "Simplified" License | 5 votes |
std::pair<double, double> getTimestampRange(const VolumeSequence &seq, bool sorted) { if (!hasTimestamps(seq)) { return std::make_pair(0.0, 1.0); } double start, end; start = getTimestamp(seq.front()); if (sorted) { end = getTimestamp(seq.back()); } else {
Example 26
Source File: delay-jitter-estimation.cc From ns3-gym with GNU General Public License v2.0 | 5 votes |
TypeId DelayJitterEstimationTimestampTag::GetTypeId (void) { static TypeId tid = TypeId ("anon::DelayJitterEstimationTimestampTag") .SetParent<Tag> () .SetGroupName("Network") .AddConstructor<DelayJitterEstimationTimestampTag> () .AddAttribute ("CreationTime", "The time at which the timestamp was created", StringValue ("0.0s"), MakeTimeAccessor (&DelayJitterEstimationTimestampTag::GetTxTime), MakeTimeChecker ()) ; return tid; }
Example 27
Source File: rtp_generator.cc From WebRTC-APM-for-Android with Apache License 2.0 | 5 votes |
uint32_t TimestampJumpRtpGenerator::GetRtpHeader(uint8_t payload_type, size_t payload_length_samples, WebRtcRTPHeader* rtp_header) { uint32_t ret = RtpGenerator::GetRtpHeader( payload_type, payload_length_samples, rtp_header); if (timestamp_ - static_cast<uint32_t>(payload_length_samples) <= jump_from_timestamp_ && timestamp_ > jump_from_timestamp_) { // We just moved across the |jump_from_timestamp_| timestamp. Do the jump. timestamp_ = jump_to_timestamp_; } return ret; }
Example 28
Source File: calculator_context_manager.cc From mediapipe with Apache License 2.0 | 5 votes |
CalculatorContext* CalculatorContextManager::GetFrontCalculatorContext( Timestamp* context_input_timestamp) { CHECK(calculator_run_in_parallel_); absl::MutexLock lock(&contexts_mutex_); CHECK(!active_contexts_.empty()); *context_input_timestamp = active_contexts_.begin()->first; return active_contexts_.begin()->second.get(); }
Example 29
Source File: mux_input_stream_handler.cc From mediapipe with Apache License 2.0 | 5 votes |
NodeReadiness GetNodeReadiness(Timestamp* min_stream_timestamp) override { DCHECK(min_stream_timestamp); absl::MutexLock lock(&input_streams_mutex_); const auto& control_stream = input_stream_managers_.Get(input_stream_managers_.EndId() - 1); bool empty; *min_stream_timestamp = control_stream->MinTimestampOrBound(&empty); if (empty) { if (*min_stream_timestamp == Timestamp::Done()) { // Calculator is done if the control input stream is done. return NodeReadiness::kReadyForClose; } // Calculator is not ready to run if the control input stream is empty. return NodeReadiness::kNotReady; } Packet control_packet = control_stream->QueueHead(); CHECK(!control_packet.IsEmpty()); int control_value = control_packet.Get<int>(); CHECK_LE(0, control_value); CHECK_LT(control_value, input_stream_managers_.NumEntries() - 1); const auto& data_stream = input_stream_managers_.Get( input_stream_managers_.BeginId() + control_value); Timestamp stream_timestamp = data_stream->MinTimestampOrBound(&empty); if (empty) { CHECK_LE(stream_timestamp, *min_stream_timestamp); return NodeReadiness::kNotReady; } CHECK_EQ(stream_timestamp, *min_stream_timestamp); return NodeReadiness::kReadyForProcess; }
Example 30
Source File: test_vertex_time_queries_test.cc From maplab with Apache License 2.0 | 5 votes |
pose_graph::VertexId getGroundTruthVertexIdClosestInTime( const int64_t query_timestamp_nanoseconds, const vi_map::MissionId& mission_id, const vi_map::VIMap::Ptr& map) { CHECK(map); CHECK(mission_id.isValid()); pose_graph::VertexIdList vertex_ids; map->getAllVertexIdsInMission(mission_id, &vertex_ids); return getGroundTruthVertexIdClosestInTime(query_timestamp_nanoseconds, vertex_ids, map); }
Example 31
Source File: test_vertex_time_queries_test.cc From maplab with Apache License 2.0 | 5 votes |
pose_graph::VertexId getGroundTruthVertexIdClosestInTime( const int64_t query_timestamp_nanoseconds, const vi_map::VIMap::Ptr& map) { CHECK(map); pose_graph::VertexIdList vertex_ids; map->getAllVertexIds(&vertex_ids); return getGroundTruthVertexIdClosestInTime(query_timestamp_nanoseconds, vertex_ids, map); }
Example 32
Source File: document_snapshot_android.cc From firebase-cpp-sdk with Apache License 2.0 | 5 votes |
FieldValue DocumentSnapshotInternal::Get(const FieldPath& field, ServerTimestampBehavior stb) const { JNIEnv* env = firestore_->app()->GetJNIEnv(); jobject field_path = FieldPathConverter::ToJavaObject(env, field); // Android returns null for both null fields and nonexistent fields, so first // use contains() to check if the field exists. jboolean contains_field = env->CallBooleanMethod( obj_, document_snapshot::GetMethodId(document_snapshot::kContains), field_path); CheckAndClearJniExceptions(env); if (!contains_field) { env->DeleteLocalRef(field_path); return FieldValue(); } else {
Example 33
Source File: document_snapshot_android.cc From firebase-cpp-sdk with Apache License 2.0 | 5 votes |
MapFieldValue DocumentSnapshotInternal::GetData( ServerTimestampBehavior stb) const { JNIEnv* env = firestore_->app()->GetJNIEnv(); jobject stb_enum = ServerTimestampBehaviorInternal::ToJavaObject(env, stb); jobject map_value = env->CallObjectMethod( obj_, document_snapshot::GetMethodId(document_snapshot::kGetData), stb_enum); CheckAndClearJniExceptions(env); FieldValueInternal value(firestore_, map_value); env->DeleteLocalRef(map_value); return value.map_value(); }
Example 34
Source File: timestamp.cpp From duckdb with MIT License | 4 votes |
Interval Timestamp::GetDifference(timestamp_t timestamp_1, timestamp_t timestamp_2) { // First extract the dates auto date1 = GetDate(timestamp_1); auto date2 = GetDate(timestamp_2); // and from date extract the years, months and days int32_t year1, month1, day1; int32_t year2, month2, day2; Date::Convert(date1, year1, month1, day1); Date::Convert(date2, year2, month2, day2); // finally perform the differences auto year_diff = year1 - year2; auto month_diff = month1 - month2; auto day_diff = day1 - day2; // Now we extract the time auto time1 = GetTime(timestamp_1); auto time2 = GetTime(timestamp_2); // In case time is not specified we do not show it in the output if (time1 == 0) { time2 = time1; } // and from time extract hours, minutes, seconds and miliseconds int32_t hour1, min1, sec1, msec1; int32_t hour2, min2, sec2, msec2; Time::Convert(time1, hour1, min1, sec1, msec1); Time::Convert(time2, hour2, min2, sec2, msec2); // finally perform the differences auto hour_diff = hour1 - hour2; auto min_diff = min1 - min2; auto sec_diff = sec1 - sec2; auto msec_diff = msec1 - msec2; // flip sign if necessary if (timestamp_1 < timestamp_2) { year_diff = -year_diff; month_diff = -month_diff; day_diff = -day_diff; hour_diff = -hour_diff; min_diff = -min_diff; sec_diff = -sec_diff; msec_diff = -msec_diff; } // now propagate any negative field into the next higher field while (msec_diff < 0) { msec_diff += MSECS_PER_SEC; sec_diff--; } while (sec_diff < 0) { sec_diff += SECS_PER_MINUTE; min_diff--; } while (min_diff < 0) { min_diff += MINS_PER_HOUR; hour_diff--; } while (hour_diff < 0) { hour_diff += HOURS_PER_DAY; day_diff--; } while (day_diff < 0) { if (timestamp_1 < timestamp_2) { day_diff += days_per_month[isleap(year1)][month1 - 1]; month_diff--; } else { day_diff += days_per_month[isleap(year2)][month2 - 1]; month_diff--; } }
Example 35
Source File: dtmf_buffer.cc From WebRTC-APM-for-Android with Apache License 2.0 | 4 votes |
bool DtmfBuffer::GetEvent(uint32_t current_timestamp, DtmfEvent* event) { DtmfList::iterator it = buffer_.begin(); while (it != buffer_.end()) { // |event_end| is an estimate of where the current event ends. If the end // bit is set, we know that the event ends at |timestamp| + |duration|. uint32_t event_end = it->timestamp + it->duration; #ifdef LEGACY_BITEXACT bool next_available = false; #endif if (!it->end_bit) { // If the end bit is not set, we allow extrapolation of the event for // some time. event_end += max_extrapolation_samples_; DtmfList::iterator next = it; ++next; if (next != buffer_.end()) { // If there is a next event in the buffer, we will not extrapolate over // the start of that new event. event_end = std::min(event_end, next->timestamp); #ifdef LEGACY_BITEXACT next_available = true; #endif } } if (current_timestamp >= it->timestamp && current_timestamp <= event_end) { // TODO(hlundin): Change to <. // Found a matching event. if (event) { event->event_no = it->event_no; event->end_bit = it->end_bit; event->volume = it->volume; event->duration = it->duration; event->timestamp = it->timestamp; } #ifdef LEGACY_BITEXACT if (it->end_bit && current_timestamp + frame_len_samples_ >= event_end) { // We are done playing this. Erase the event. buffer_.erase(it); } #endif return true; } else if (current_timestamp > event_end) { // TODO(hlundin): Change to >=. // Erase old event. Operation returns a valid pointer to the next element // in the list. #ifdef LEGACY_BITEXACT if (!next_available) { if (event) { event->event_no = it->event_no; event->end_bit = it->end_bit; event->volume = it->volume; event->duration = it->duration; event->timestamp = it->timestamp; } it = buffer_.erase(it); return true; } else { it = buffer_.erase(it); } #else it = buffer_.erase(it); #endif }
Example 36
Source File: utils.cpp From ledger with Apache License 2.0 | 4 votes |
std::string GetStrTimestamp() { auto now = std::chrono::system_clock::now(); auto in_time_t = std::chrono::system_clock::to_time_t(now); auto now_milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000; std::stringstream ss; ss << std::put_time(std::gmtime(&in_time_t), "%Y-%m-%d-%H:%M:%S"); // add milliseconds to timestamp string ss << '.' << std::setfill('0') << std::setw(3) << now_milliseconds.count(); return ss.str(); }
Example 37
Source File: dx11_utils.cc From gpu_performance_api with MIT License | 4 votes |
bool DX11Utils::GetTimestampFrequency(ID3D11Device* pD3D11Device, UINT64& timestampFrequency) { bool success = false; if (nullptr != pD3D11Device) { ID3D11Query* timeStampDisjointQuery = nullptr; D3D11_QUERY_DESC timeStampDesc; timeStampDesc.Query = D3D11_QUERY_TIMESTAMP_DISJOINT; timeStampDesc.MiscFlags = 0; HRESULT hr = E_FAIL; hr = pD3D11Device->CreateQuery(&timeStampDesc, &timeStampDisjointQuery); #ifdef _DEBUG D3D_SET_OBJECT_NAME_A(timeStampDisjointQuery, "GPA_TimestampFrequencyQuery"); #endif if (SUCCEEDED(hr)) { // get immediate context ID3D11DeviceContext* pD3DContext = nullptr; pD3D11Device->GetImmediateContext(&pD3DContext); if (nullptr != pD3DContext) { //Submit the query pD3DContext->Begin(timeStampDisjointQuery); pD3DContext->End(timeStampDisjointQuery); // need to loop on checking the values, it may not be immediately available. HRESULT dataReady = S_OK; do { dataReady = pD3DContext->GetData(timeStampDisjointQuery, nullptr, 0, 0); if (FAILED(dataReady)) { GPA_LogError("Call to ID3D11DeviceContext::GetData failed."); return false; } } while (S_FALSE == dataReady); // S_OK == data ready; S_FALSE == data not ready D3D11_QUERY_DATA_TIMESTAMP_DISJOINT timeStampDisjoint; assert(timeStampDisjointQuery->GetDataSize() == sizeof(D3D11_QUERY_DATA_TIMESTAMP_DISJOINT)); hr = pD3DContext->GetData(timeStampDisjointQuery, &timeStampDisjoint, sizeof(D3D11_QUERY_DATA_TIMESTAMP_DISJOINT), 0); timestampFrequency = timeStampDisjoint.Frequency; assert(SUCCEEDED(hr)); success = true; pD3DContext->Release(); timeStampDisjointQuery->Release(); timeStampDisjointQuery = nullptr; } else { GPA_LogError("GetTimestampFrequency Immediate Context is NULL."); } } else {