| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/debug/invalidation_benchmark.h" | 5 #include "cc/debug/invalidation_benchmark.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 bool InvalidationBenchmark::ProcessMessage(scoped_ptr<base::Value> value) { | 109 bool InvalidationBenchmark::ProcessMessage(scoped_ptr<base::Value> value) { |
| 110 base::DictionaryValue* message = nullptr; | 110 base::DictionaryValue* message = nullptr; |
| 111 value->GetAsDictionary(&message); | 111 value->GetAsDictionary(&message); |
| 112 if (!message) | 112 if (!message) |
| 113 return false; | 113 return false; |
| 114 | 114 |
| 115 bool notify_done; | 115 bool notify_done; |
| 116 if (message->HasKey("notify_done")) { | 116 if (message->HasKey("notify_done")) { |
| 117 message->GetBoolean("notify_done", ¬ify_done); | 117 message->GetBoolean("notify_done", ¬ify_done); |
| 118 if (notify_done) | 118 if (notify_done) |
| 119 NotifyDone(scoped_ptr<base::Value>(base::Value::CreateNullValue())); | 119 NotifyDone(base::Value::CreateNullValue()); |
| 120 return true; | 120 return true; |
| 121 } | 121 } |
| 122 return false; | 122 return false; |
| 123 } | 123 } |
| 124 | 124 |
| 125 // A simple linear congruential generator. The random numbers don't need to be | 125 // A simple linear congruential generator. The random numbers don't need to be |
| 126 // high quality, but they need to be identical in each run. Therefore, we use a | 126 // high quality, but they need to be identical in each run. Therefore, we use a |
| 127 // LCG and keep the state locally in the benchmark. | 127 // LCG and keep the state locally in the benchmark. |
| 128 float InvalidationBenchmark::LCGRandom() { | 128 float InvalidationBenchmark::LCGRandom() { |
| 129 const uint32 a = 1664525; | 129 const uint32 a = 1664525; |
| 130 const uint32 c = 1013904223; | 130 const uint32 c = 1013904223; |
| 131 seed_ = a * seed_ + c; | 131 seed_ = a * seed_ + c; |
| 132 return static_cast<float>(seed_) / std::numeric_limits<uint32>::max(); | 132 return static_cast<float>(seed_) / std::numeric_limits<uint32>::max(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace cc | 135 } // namespace cc |
| OLD | NEW |