mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
Beast includes a lot of code for encapsulating cross-platform differences which are not used or needed by rippled. Additionally, a lot of that code implements functionality that is available from the standard library. This moves away from custom implementations of features that the standard library provides and reduces the number of platform-specific interfaces andfeatures that Beast makes available. Highlights include: * Use std:: instead of beast implementations when possible * Reduce the use of beast::String in public interfaces * Remove Windows-specific COM and Registry code * Reduce the public interface of beast::File * Reduce the public interface of beast::SystemStats * Remove unused sysctl/getsysinfo functions * Remove beast::Logger
68 lines
2.1 KiB
C++
68 lines
2.1 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of Beast: https://github.com/vinniefalco/Beast
|
|
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
|
|
|
Portions of this file are from JUCE.
|
|
Copyright (c) 2013 - Raw Material Software Ltd.
|
|
Please visit http://www.juce.com
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
|
|
//==============================================================================
|
|
|
|
void outputDebugString (std::string const& text)
|
|
{
|
|
std::cerr << text << std::endl;
|
|
}
|
|
|
|
//==============================================================================
|
|
std::string SystemStats::getComputerName()
|
|
{
|
|
char name [256] = { 0 };
|
|
if (gethostname (name, sizeof (name) - 1) == 0)
|
|
return name;
|
|
|
|
return std::string{};
|
|
}
|
|
|
|
//==============================================================================
|
|
std::uint32_t beast_millisecondsSinceStartup() noexcept
|
|
{
|
|
timespec t;
|
|
clock_gettime (CLOCK_MONOTONIC, &t);
|
|
|
|
return t.tv_sec * 1000 + t.tv_nsec / 1000000;
|
|
}
|
|
|
|
std::int64_t Time::getHighResolutionTicks() noexcept
|
|
{
|
|
timespec t;
|
|
clock_gettime (CLOCK_MONOTONIC, &t);
|
|
|
|
return (t.tv_sec * (std::int64_t) 1000000) + (t.tv_nsec / 1000);
|
|
}
|
|
|
|
std::int64_t Time::getHighResolutionTicksPerSecond() noexcept
|
|
{
|
|
return 1000000; // (microseconds)
|
|
}
|
|
|
|
double Time::getMillisecondCounterHiRes() noexcept
|
|
{
|
|
return getHighResolutionTicks() * 0.001;
|
|
}
|
|
|
|
} // beast
|