Big purge of base
- Delete AtExit, FilePathWatcher, MemoryMappedFile, MessageLoop,
TaskScheduler, most of threading/
- Delete third_party/libevent, third_party/dmg_fp (this makes the json
reader not-exactly-json any more because it doesn't support doubles, but
GN already disallowed doubles.)
- Add src/msg_loop.*.
After all the deleting and mucking around, a simple perf comparison
against the current in-tree Chrome gn:
c:\src\gn>python build\full_test.py \src\cr\src out\wi\gn.exe
ninja: Entering directory `out'
ninja: no work to do.
[430/430] XmlElementWriter.TestXmlEscape
PASSED
Confirming output matches...
Comparing performance... (takes a while)
In-tree gn avg: 13.522s
Our gn avg: 11.822s
This isn't rock-solid, but it seems like it's at least not slower.
Change-Id: Id956ffdbb909b1398465098d349b57e10589b27d
Reviewed-on: https://gn-review.googlesource.com/1600
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Brett Wilson <brettw@chromium.org>
diff --git a/src/sys_info.cc b/src/sys_info.cc
new file mode 100644
index 0000000..ad71b6f
--- /dev/null
+++ b/src/sys_info.cc
@@ -0,0 +1,81 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sys_info.h"
+
+#include "base/logging.h"
+#include "build_config.h"
+
+#if defined(OS_POSIX)
+#include <sys/utsname.h>
+#include <unistd.h>
+#endif
+
+#if defined(OS_WIN)
+#include <windows.h>
+#endif
+
+std::string OperatingSystemArchitecture() {
+#if defined(OS_POSIX)
+ struct utsname info;
+ if (uname(&info) < 0) {
+ NOTREACHED();
+ return std::string();
+ }
+ std::string arch(info.machine);
+ if (arch == "i386" || arch == "i486" || arch == "i586" || arch == "i686") {
+ arch = "x86";
+ } else if (arch == "amd64") {
+ arch = "x86_64";
+ } else if (std::string(info.sysname) == "AIX") {
+ arch = "ppc64";
+ }
+ return arch;
+#elif defined(OS_WIN)
+ SYSTEM_INFO system_info = {};
+ ::GetNativeSystemInfo(&system_info);
+ switch (system_info.wProcessorArchitecture) {
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ return "x86";
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ return "x86_64";
+ case PROCESSOR_ARCHITECTURE_IA64:
+ return "ia64";
+ }
+ return std::string();
+#else
+#error
+#endif
+}
+
+int NumberOfProcessors() {
+#if defined(OS_POSIX)
+ // sysconf returns the number of "logical" (not "physical") processors on both
+ // Mac and Linux. So we get the number of max available "logical" processors.
+ //
+ // Note that the number of "currently online" processors may be fewer than the
+ // returned value of NumberOfProcessors(). On some platforms, the kernel may
+ // make some processors offline intermittently, to save power when system
+ // loading is low.
+ //
+ // One common use case that needs to know the processor count is to create
+ // optimal number of threads for optimization. It should make plan according
+ // to the number of "max available" processors instead of "currently online"
+ // ones. The kernel should be smart enough to make all processors online when
+ // it has sufficient number of threads waiting to run.
+ long res = sysconf(_SC_NPROCESSORS_CONF);
+ if (res == -1) {
+ NOTREACHED();
+ return 1;
+ }
+
+ return static_cast<int>(res);
+#elif defined(OS_WIN)
+ SYSTEM_INFO system_info = {};
+ ::GetNativeSystemInfo(&system_info);
+ return system_info.dwNumberOfProcessors;
+#else
+#error
+#endif
+}