Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Side by Side Diff: src/platform-win32.cc

Issue 11033014: Revert "Adding a high-resolution timer to platform win32." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 584
585 585
586 // Returns current time as the number of milliseconds since 586 // Returns current time as the number of milliseconds since
587 // 00:00:00 UTC, January 1, 1970. 587 // 00:00:00 UTC, January 1, 1970.
588 double OS::TimeCurrentMillis() { 588 double OS::TimeCurrentMillis() {
589 Time t; 589 Time t;
590 t.SetToCurrentTime(); 590 t.SetToCurrentTime();
591 return t.ToJSTime(); 591 return t.ToJSTime();
592 } 592 }
593 593
594 594 // Returns the tickcounter based on timeGetTime.
595 static LARGE_INTEGER frequency = 0;
596
597
598 // Returns the tickcounter based on QueryPerformanceCounter or timeGetTime.
599 int64_t OS::Ticks() { 595 int64_t OS::Ticks() {
600 static LARGE_INTEGER tick;
601 if (frequency != 0 && QueryPerformanceCounter(&tick)) {
602 return static_cast<int64_t>(tick.QuadPart * 1e6 / frequency->QuadPart);
603 }
604 return timeGetTime() * 1000; // Convert to microseconds. 596 return timeGetTime() * 1000; // Convert to microseconds.
605 } 597 }
606 598
607 599
608 // Returns a string identifying the current timezone taking into 600 // Returns a string identifying the current timezone taking into
609 // account daylight saving. 601 // account daylight saving.
610 const char* OS::LocalTimezone(double time) { 602 const char* OS::LocalTimezone(double time) {
611 return Time(time).LocalTimezone(); 603 return Time(time).LocalTimezone();
612 } 604 }
613 605
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 2080
2089 2081
2090 void OS::SetUp() { 2082 void OS::SetUp() {
2091 // Seed the random number generator. 2083 // Seed the random number generator.
2092 // Convert the current time to a 64-bit integer first, before converting it 2084 // Convert the current time to a 64-bit integer first, before converting it
2093 // to an unsigned. Going directly can cause an overflow and the seed to be 2085 // to an unsigned. Going directly can cause an overflow and the seed to be
2094 // set to all ones. The seed will be identical for different instances that 2086 // set to all ones. The seed will be identical for different instances that
2095 // call this setup code within the same millisecond. 2087 // call this setup code within the same millisecond.
2096 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); 2088 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
2097 srand(static_cast<unsigned int>(seed)); 2089 srand(static_cast<unsigned int>(seed));
2098 // Get the number of ticks per second that is used in OS::Ticks()
2099 QueryPerformanceFrequency(&frequency);
2100 limit_mutex = CreateMutex(); 2090 limit_mutex = CreateMutex();
2101 SamplerThread::SetUp(); 2091 SamplerThread::SetUp();
2102 } 2092 }
2103 2093
2104 2094
2105 void OS::TearDown() { 2095 void OS::TearDown() {
2106 frequency = 0;
2107 SamplerThread::TearDown(); 2096 SamplerThread::TearDown();
2108 delete limit_mutex; 2097 delete limit_mutex;
2109 } 2098 }
2110 2099
2111 2100
2112 Sampler::Sampler(Isolate* isolate, int interval) 2101 Sampler::Sampler(Isolate* isolate, int interval)
2113 : isolate_(isolate), 2102 : isolate_(isolate),
2114 interval_(interval), 2103 interval_(interval),
2115 profiling_(false), 2104 profiling_(false),
2116 active_(false), 2105 active_(false),
(...skipping 21 matching lines...) Expand all
2138 2127
2139 2128
2140 void Sampler::Stop() { 2129 void Sampler::Stop() {
2141 ASSERT(IsActive()); 2130 ASSERT(IsActive());
2142 SamplerThread::RemoveActiveSampler(this); 2131 SamplerThread::RemoveActiveSampler(this);
2143 SetActive(false); 2132 SetActive(false);
2144 } 2133 }
2145 2134
2146 2135
2147 } } // namespace v8::internal 2136 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698