mirror of https://github.com/aristocratos/btop.git
Use unordered_dense hash map
This commit is contained in:
parent
ebc46ca12c
commit
2fb70c8e9f
File diff suppressed because it is too large
Load Diff
2544
include/robin_hood.h
2544
include/robin_hood.h
File diff suppressed because it is too large
Load Diff
|
@ -43,6 +43,7 @@ tab-size = 4
|
|||
#include <semaphore>
|
||||
#endif
|
||||
|
||||
#include "ankerl/unordered_dense.h"
|
||||
#include "btop_shared.hpp"
|
||||
#include "btop_tools.hpp"
|
||||
#include "btop_config.hpp"
|
||||
|
@ -416,7 +417,7 @@ namespace Runner {
|
|||
};
|
||||
|
||||
string debug_bg;
|
||||
unordered_flat_map<string, array<uint64_t, 2>> debug_times;
|
||||
ankerl::unordered_dense::map<string, array<uint64_t, 2>> debug_times;
|
||||
|
||||
class MyNumPunct : public std::numpunct<char>
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@ tab-size = 4
|
|||
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include "ankerl/unordered_dense.h"
|
||||
#include "btop_config.hpp"
|
||||
#include "btop_shared.hpp"
|
||||
#include "btop_tools.hpp"
|
||||
|
@ -215,7 +216,7 @@ namespace Config {
|
|||
#endif
|
||||
};
|
||||
|
||||
unordered_flat_map<std::string_view, string> strings = {
|
||||
ankerl::unordered_dense::map<std::string_view, string> strings = {
|
||||
{"color_theme", "Default"},
|
||||
{"shown_boxes", "cpu mem net proc"},
|
||||
{"graph_symbol", "braille"},
|
||||
|
@ -251,9 +252,9 @@ namespace Config {
|
|||
{"show_gpu_info", "Auto"}
|
||||
#endif
|
||||
};
|
||||
unordered_flat_map<std::string_view, string> stringsTmp;
|
||||
ankerl::unordered_dense::map<std::string_view, string> stringsTmp;
|
||||
|
||||
unordered_flat_map<std::string_view, bool> bools = {
|
||||
ankerl::unordered_dense::map<std::string_view, bool> bools = {
|
||||
{"theme_background", true},
|
||||
{"truecolor", true},
|
||||
{"rounded_corners", true},
|
||||
|
@ -304,9 +305,9 @@ namespace Config {
|
|||
{"gpu_mirror_graph", true},
|
||||
#endif
|
||||
};
|
||||
unordered_flat_map<std::string_view, bool> boolsTmp;
|
||||
ankerl::unordered_dense::map<std::string_view, bool> boolsTmp;
|
||||
|
||||
unordered_flat_map<std::string_view, int> ints = {
|
||||
ankerl::unordered_dense::map<std::string_view, int> ints = {
|
||||
{"update_ms", 2000},
|
||||
{"net_download", 100},
|
||||
{"net_upload", 100},
|
||||
|
@ -317,7 +318,7 @@ namespace Config {
|
|||
{"proc_selected", 0},
|
||||
{"proc_last_selected", 0},
|
||||
};
|
||||
unordered_flat_map<std::string_view, int> intsTmp;
|
||||
ankerl::unordered_dense::map<std::string_view, int> intsTmp;
|
||||
|
||||
bool _locked(const std::string_view name) {
|
||||
atomic_wait(writelock, true);
|
||||
|
|
|
@ -22,11 +22,10 @@ tab-size = 4
|
|||
#include <vector>
|
||||
#include <filesystem>
|
||||
|
||||
#include <robin_hood.h>
|
||||
#include "ankerl/unordered_dense.h"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using robin_hood::unordered_flat_map;
|
||||
|
||||
//* Functions and variables for reading and writing the btop config file
|
||||
namespace Config {
|
||||
|
@ -34,12 +33,12 @@ namespace Config {
|
|||
extern std::filesystem::path conf_dir;
|
||||
extern std::filesystem::path conf_file;
|
||||
|
||||
extern unordered_flat_map<std::string_view, string> strings;
|
||||
extern unordered_flat_map<std::string_view, string> stringsTmp;
|
||||
extern unordered_flat_map<std::string_view, bool> bools;
|
||||
extern unordered_flat_map<std::string_view, bool> boolsTmp;
|
||||
extern unordered_flat_map<std::string_view, int> ints;
|
||||
extern unordered_flat_map<std::string_view, int> intsTmp;
|
||||
extern ankerl::unordered_dense::map<std::string_view, string> strings;
|
||||
extern ankerl::unordered_dense::map<std::string_view, string> stringsTmp;
|
||||
extern ankerl::unordered_dense::map<std::string_view, bool> bools;
|
||||
extern ankerl::unordered_dense::map<std::string_view, bool> boolsTmp;
|
||||
extern ankerl::unordered_dense::map<std::string_view, int> ints;
|
||||
extern ankerl::unordered_dense::map<std::string_view, int> intsTmp;
|
||||
|
||||
const vector<string> valid_graph_symbols = { "braille", "block", "tty" };
|
||||
const vector<string> valid_graph_symbols_def = { "default", "braille", "block", "tty" };
|
||||
|
|
|
@ -22,7 +22,9 @@ tab-size = 4
|
|||
#include <ranges>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "ankerl/unordered_dense.h"
|
||||
#include "btop_draw.hpp"
|
||||
#include "btop_config.hpp"
|
||||
#include "btop_theme.hpp"
|
||||
|
@ -54,7 +56,7 @@ namespace Symbols {
|
|||
|
||||
const array<string, 10> superscript = { "⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹" };
|
||||
|
||||
const unordered_flat_map<string, vector<string>> graph_symbols = {
|
||||
const ankerl::unordered_dense::map<string, vector<string>> graph_symbols = {
|
||||
{ "braille_up", {
|
||||
" ", "⢀", "⢠", "⢰", "⢸",
|
||||
"⡀", "⣀", "⣠", "⣰", "⣸",
|
||||
|
@ -300,7 +302,7 @@ namespace Draw {
|
|||
return false;
|
||||
}
|
||||
|
||||
static const unordered_flat_map<string, string> clock_custom_format = {
|
||||
static const ankerl::unordered_dense::map<string, string> clock_custom_format = {
|
||||
{"/user", Tools::username()},
|
||||
{"/host", Tools::hostname()},
|
||||
{"/uptime", ""}
|
||||
|
@ -707,7 +709,7 @@ namespace Cpu {
|
|||
static long old_seconds{}; // defaults to = 0
|
||||
static string old_status;
|
||||
static Draw::Meter bat_meter {10, "cpu", true};
|
||||
static const unordered_flat_map<string, string> bat_symbols = {
|
||||
static const ankerl::unordered_dense::map<string, string> bat_symbols = {
|
||||
{"charging", "▲"},
|
||||
{"discharging", "▼"},
|
||||
{"full", "■"},
|
||||
|
@ -1096,11 +1098,11 @@ namespace Mem {
|
|||
int disks_io_half = 0;
|
||||
bool shown = true, redraw = true;
|
||||
string box;
|
||||
unordered_flat_map<string, Draw::Meter> mem_meters;
|
||||
unordered_flat_map<string, Draw::Graph> mem_graphs;
|
||||
unordered_flat_map<string, Draw::Meter> disk_meters_used;
|
||||
unordered_flat_map<string, Draw::Meter> disk_meters_free;
|
||||
unordered_flat_map<string, Draw::Graph> io_graphs;
|
||||
ankerl::unordered_dense::map<string, Draw::Meter> mem_meters;
|
||||
ankerl::unordered_dense::map<string, Draw::Graph> mem_graphs;
|
||||
ankerl::unordered_dense::map<string, Draw::Meter> disk_meters_used;
|
||||
ankerl::unordered_dense::map<string, Draw::Meter> disk_meters_free;
|
||||
ankerl::unordered_dense::map<string, Draw::Graph> io_graphs;
|
||||
|
||||
string draw(const mem_info& mem, bool force_redraw, bool data_same) {
|
||||
if (Runner::stopping) return "";
|
||||
|
@ -1148,7 +1150,7 @@ namespace Mem {
|
|||
//? Disk meters and io graphs
|
||||
if (show_disks) {
|
||||
if (show_io_stat or io_mode) {
|
||||
unordered_flat_map<string, int> custom_speeds;
|
||||
ankerl::unordered_dense::map<string, int> custom_speeds;
|
||||
int half_height = 0;
|
||||
if (io_mode) {
|
||||
disks_io_h = max((int)floor((double)(height - 2 - (disk_ios * 2)) / max(1, disk_ios)), (io_graph_combined ? 1 : 2));
|
||||
|
@ -1353,7 +1355,7 @@ namespace Net {
|
|||
int b_x, b_y, b_width, b_height, d_graph_height, u_graph_height;
|
||||
bool shown = true, redraw = true;
|
||||
string old_ip;
|
||||
unordered_flat_map<string, Draw::Graph> graphs;
|
||||
ankerl::unordered_dense::map<string, Draw::Graph> graphs;
|
||||
string box;
|
||||
|
||||
string draw(const net_info& net, bool force_redraw, bool data_same) {
|
||||
|
@ -1453,9 +1455,9 @@ namespace Proc {
|
|||
bool shown = true, redraw = true;
|
||||
int selected_pid = 0, selected_depth = 0;
|
||||
string selected_name;
|
||||
unordered_flat_map<size_t, Draw::Graph> p_graphs;
|
||||
unordered_flat_map<size_t, bool> p_wide_cmd;
|
||||
unordered_flat_map<size_t, int> p_counters;
|
||||
ankerl::unordered_dense::map<size_t, Draw::Graph> p_graphs;
|
||||
ankerl::unordered_dense::map<size_t, bool> p_wide_cmd;
|
||||
ankerl::unordered_dense::map<size_t, int> p_counters;
|
||||
int counter = 0;
|
||||
Draw::TextEdit filter;
|
||||
Draw::Graph detailed_cpu_graph;
|
||||
|
@ -1926,8 +1928,8 @@ namespace Proc {
|
|||
else
|
||||
++element;
|
||||
}
|
||||
p_graphs.compact();
|
||||
p_counters.compact();
|
||||
p_graphs.rehash(0);
|
||||
p_counters.rehash(0);
|
||||
|
||||
for (auto element = p_wide_cmd.begin(); element != p_wide_cmd.end();) {
|
||||
if (rng::find(plist, element->first, &proc_info::pid) == plist.end()) {
|
||||
|
@ -1936,7 +1938,7 @@ namespace Proc {
|
|||
else
|
||||
++element;
|
||||
}
|
||||
p_wide_cmd.compact();
|
||||
p_wide_cmd.rehash(0);
|
||||
}
|
||||
|
||||
if (selected == 0 and selected_pid != 0) {
|
||||
|
|
|
@ -21,10 +21,10 @@ tab-size = 4
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <robin_hood.h>
|
||||
#include <deque>
|
||||
|
||||
using robin_hood::unordered_flat_map;
|
||||
#include "ankerl/unordered_dense.h"
|
||||
|
||||
using std::array;
|
||||
using std::deque;
|
||||
using std::string;
|
||||
|
@ -108,7 +108,7 @@ namespace Draw {
|
|||
long long offset;
|
||||
long long last = 0, max_value = 0;
|
||||
bool current = true, tty_mode = false;
|
||||
unordered_flat_map<bool, vector<string>> graphs = { {true, {}}, {false, {}}};
|
||||
ankerl::unordered_dense::map<bool, vector<string>> graphs = { {true, {}}, {false, {}}};
|
||||
|
||||
//* Create two representations of the graph to switch between to represent two values for each braille character
|
||||
void _create(const deque<long long>& data, int data_offset);
|
||||
|
@ -135,6 +135,6 @@ namespace Draw {
|
|||
|
||||
namespace Proc {
|
||||
extern Draw::TextEdit filter;
|
||||
extern unordered_flat_map<size_t, Draw::Graph> p_graphs;
|
||||
extern unordered_flat_map<size_t, int> p_counters;
|
||||
extern ankerl::unordered_dense::map<size_t, Draw::Graph> p_graphs;
|
||||
extern ankerl::unordered_dense::map<size_t, int> p_counters;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ tab-size = 4
|
|||
#include <vector>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <utility>
|
||||
#include <signal.h>
|
||||
#include <utility>
|
||||
|
||||
|
@ -32,6 +33,7 @@ tab-size = 4
|
|||
#include "btop_draw.hpp"
|
||||
|
||||
|
||||
#include "ankerl/unordered_dense.h"
|
||||
#include "btop_input.hpp"
|
||||
#include "btop_tools.hpp"
|
||||
#include "btop_config.hpp"
|
||||
|
@ -49,7 +51,7 @@ namespace rng = std::ranges;
|
|||
namespace Input {
|
||||
|
||||
//* Map for translating key codes to readable values
|
||||
const unordered_flat_map<string, string> Key_escapes = {
|
||||
const ankerl::unordered_dense::map<string, string> Key_escapes = {
|
||||
{"\033", "escape"},
|
||||
{"\n", "enter"},
|
||||
{" ", "space"},
|
||||
|
@ -92,7 +94,7 @@ namespace Input {
|
|||
std::atomic<bool> interrupt (false);
|
||||
std::atomic<bool> polling (false);
|
||||
array<int, 2> mouse_pos;
|
||||
unordered_flat_map<string, Mouse_loc> mouse_mappings;
|
||||
ankerl::unordered_dense::map<string, Mouse_loc> mouse_mappings;
|
||||
|
||||
deque<string> history(50, "");
|
||||
string old_filter;
|
||||
|
|
|
@ -21,10 +21,10 @@ tab-size = 4
|
|||
#include <string>
|
||||
#include <atomic>
|
||||
#include <array>
|
||||
#include <robin_hood.h>
|
||||
#include <deque>
|
||||
|
||||
using robin_hood::unordered_flat_map;
|
||||
#include "ankerl/unordered_dense.h"
|
||||
|
||||
using std::array;
|
||||
using std::atomic;
|
||||
using std::deque;
|
||||
|
@ -44,7 +44,7 @@ namespace Input {
|
|||
};
|
||||
|
||||
//? line, col, height, width
|
||||
extern unordered_flat_map<string, Mouse_loc> mouse_mappings;
|
||||
extern ankerl::unordered_dense::map<string, Mouse_loc> mouse_mappings;
|
||||
|
||||
extern atomic<bool> interrupt;
|
||||
extern atomic<bool> polling;
|
||||
|
|
|
@ -17,13 +17,13 @@ tab-size = 4
|
|||
*/
|
||||
|
||||
#include <deque>
|
||||
#include <robin_hood.h>
|
||||
#include <array>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <cmath>
|
||||
#include <filesystem>
|
||||
|
||||
#include "ankerl/unordered_dense.h"
|
||||
#include "btop_menu.hpp"
|
||||
#include "btop_tools.hpp"
|
||||
#include "btop_config.hpp"
|
||||
|
@ -31,7 +31,6 @@ tab-size = 4
|
|||
#include "btop_draw.hpp"
|
||||
#include "btop_shared.hpp"
|
||||
|
||||
using robin_hood::unordered_flat_map;
|
||||
using std::array;
|
||||
using std::ceil;
|
||||
using std::max;
|
||||
|
@ -123,7 +122,7 @@ namespace Menu {
|
|||
#endif
|
||||
};
|
||||
|
||||
unordered_flat_map<string, Input::Mouse_loc> mouse_mappings;
|
||||
ankerl::unordered_dense::map<string, Input::Mouse_loc> mouse_mappings;
|
||||
|
||||
const array<array<string, 3>, 3> menu_normal = {
|
||||
array<string, 3>{
|
||||
|
@ -1165,7 +1164,7 @@ namespace Menu {
|
|||
static Draw::TextEdit editor;
|
||||
static string warnings;
|
||||
static bitset<8> selPred;
|
||||
static const unordered_flat_map<string, std::reference_wrapper<const vector<string>>> optionsList = {
|
||||
static const ankerl::unordered_dense::map<string, std::reference_wrapper<const vector<string>>> optionsList = {
|
||||
{"color_theme", std::cref(Theme::themes)},
|
||||
{"log_level", std::cref(Logger::log_levels)},
|
||||
{"temp_scale", std::cref(Config::temp_scales)},
|
||||
|
|
|
@ -23,6 +23,7 @@ tab-size = 4
|
|||
#include <vector>
|
||||
#include <bitset>
|
||||
|
||||
#include "ankerl/unordered_dense.h"
|
||||
#include "btop_input.hpp"
|
||||
|
||||
using std::atomic;
|
||||
|
@ -38,7 +39,7 @@ namespace Menu {
|
|||
extern bool redraw;
|
||||
|
||||
//? line, col, height, width
|
||||
extern unordered_flat_map<string, Input::Mouse_loc> mouse_mappings;
|
||||
extern ankerl::unordered_dense::map<string, Input::Mouse_loc> mouse_mappings;
|
||||
|
||||
//* Creates a message box centered on screen
|
||||
//? Height of box is determined by size of content vector
|
||||
|
|
|
@ -26,10 +26,10 @@ tab-size = 4
|
|||
#include <tuple>
|
||||
#include <vector>
|
||||
#include <ifaddrs.h>
|
||||
#include <robin_hood.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using robin_hood::unordered_flat_map;
|
||||
#include "ankerl/unordered_dense.h"
|
||||
|
||||
using std::array;
|
||||
using std::atomic;
|
||||
using std::deque;
|
||||
|
@ -181,7 +181,7 @@ namespace Cpu {
|
|||
extern tuple<int, long, string> current_bat;
|
||||
|
||||
struct cpu_info {
|
||||
unordered_flat_map<string, deque<long long>> cpu_percent = {
|
||||
ankerl::unordered_dense::map<string, deque<long long>> cpu_percent = {
|
||||
{"total", {}},
|
||||
{"user", {}},
|
||||
{"nice", {}},
|
||||
|
@ -207,8 +207,8 @@ namespace Cpu {
|
|||
string draw(const cpu_info& cpu, const vector<Gpu::gpu_info>& gpu, bool force_redraw = false, bool data_same = false);
|
||||
|
||||
//* Parse /proc/cpu info for mapping of core ids
|
||||
auto get_core_mapping() -> unordered_flat_map<int, int>;
|
||||
extern unordered_flat_map<int, int> core_mapping;
|
||||
auto get_core_mapping() -> ankerl::unordered_dense::map<int, int>;
|
||||
extern ankerl::unordered_dense::map<int, int> core_mapping;
|
||||
|
||||
//* Get battery info from /sys
|
||||
auto get_battery() -> tuple<int, long, string>;
|
||||
|
@ -240,13 +240,13 @@ namespace Mem {
|
|||
};
|
||||
|
||||
struct mem_info {
|
||||
unordered_flat_map<string, uint64_t> stats =
|
||||
ankerl::unordered_dense::map<string, uint64_t> stats =
|
||||
{{"used", 0}, {"available", 0}, {"cached", 0}, {"free", 0},
|
||||
{"swap_total", 0}, {"swap_used", 0}, {"swap_free", 0}};
|
||||
unordered_flat_map<string, deque<long long>> percent =
|
||||
ankerl::unordered_dense::map<string, deque<long long>> percent =
|
||||
{{"used", {}}, {"available", {}}, {"cached", {}}, {"free", {}},
|
||||
{"swap_total", {}}, {"swap_used", {}}, {"swap_free", {}}};
|
||||
unordered_flat_map<string, disk_info> disks;
|
||||
ankerl::unordered_dense::map<string, disk_info> disks;
|
||||
vector<string> disks_order;
|
||||
};
|
||||
|
||||
|
@ -268,7 +268,7 @@ namespace Net {
|
|||
extern string selected_iface;
|
||||
extern vector<string> interfaces;
|
||||
extern bool rescale;
|
||||
extern unordered_flat_map<string, uint64_t> graph_max;
|
||||
extern ankerl::unordered_dense::map<string, uint64_t> graph_max;
|
||||
|
||||
struct net_stat {
|
||||
uint64_t speed{}; // defaults to 0
|
||||
|
@ -280,14 +280,14 @@ namespace Net {
|
|||
};
|
||||
|
||||
struct net_info {
|
||||
unordered_flat_map<string, deque<long long>> bandwidth = { {"download", {}}, {"upload", {}} };
|
||||
unordered_flat_map<string, net_stat> stat = { {"download", {}}, {"upload", {}} };
|
||||
ankerl::unordered_dense::map<string, deque<long long>> bandwidth = { {"download", {}}, {"upload", {}} };
|
||||
ankerl::unordered_dense::map<string, net_stat> stat = { {"download", {}}, {"upload", {}} };
|
||||
string ipv4{}; // defaults to ""
|
||||
string ipv6{}; // defaults to ""
|
||||
bool connected{}; // defaults to false
|
||||
};
|
||||
|
||||
extern unordered_flat_map<string, net_info> current_net;
|
||||
extern ankerl::unordered_dense::map<string, net_info> current_net;
|
||||
|
||||
//* Collect net upload/download stats
|
||||
auto collect(bool no_update=false) -> net_info&;
|
||||
|
@ -320,7 +320,7 @@ namespace Proc {
|
|||
};
|
||||
|
||||
//? Translation from process state char to explanative string
|
||||
const unordered_flat_map<char, string> proc_states = {
|
||||
const ankerl::unordered_dense::map<char, string> proc_states = {
|
||||
{'R', "Running"},
|
||||
{'S', "Sleeping"},
|
||||
{'D', "Waiting"},
|
||||
|
|
|
@ -20,6 +20,7 @@ tab-size = 4
|
|||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ankerl/unordered_dense.h"
|
||||
#include "btop_tools.hpp"
|
||||
#include "btop_config.hpp"
|
||||
#include "btop_theme.hpp"
|
||||
|
@ -42,11 +43,11 @@ namespace Theme {
|
|||
fs::path theme_dir;
|
||||
fs::path user_theme_dir;
|
||||
vector<string> themes;
|
||||
unordered_flat_map<string, string> colors;
|
||||
unordered_flat_map<string, array<int, 3>> rgbs;
|
||||
unordered_flat_map<string, array<string, 101>> gradients;
|
||||
ankerl::unordered_dense::map<string, string> colors;
|
||||
ankerl::unordered_dense::map<string, array<int, 3>> rgbs;
|
||||
ankerl::unordered_dense::map<string, array<string, 101>> gradients;
|
||||
|
||||
const unordered_flat_map<string, string> Default_theme = {
|
||||
const ankerl::unordered_dense::map<string, string> Default_theme = {
|
||||
{ "main_bg", "#00" },
|
||||
{ "main_fg", "#cc" },
|
||||
{ "title", "#ee" },
|
||||
|
@ -91,7 +92,7 @@ namespace Theme {
|
|||
{ "process_end", "#d45454" }
|
||||
};
|
||||
|
||||
const unordered_flat_map<string, string> TTY_theme = {
|
||||
const ankerl::unordered_dense::map<string, string> TTY_theme = {
|
||||
{ "main_bg", "\x1b[0;40m" },
|
||||
{ "main_fg", "\x1b[37m" },
|
||||
{ "title", "\x1b[97m" },
|
||||
|
@ -224,7 +225,7 @@ namespace Theme {
|
|||
}
|
||||
|
||||
//* Generate colors and rgb decimal vectors for the theme
|
||||
void generateColors(const unordered_flat_map<string, string>& source) {
|
||||
void generateColors(const ankerl::unordered_dense::map<string, string>& source) {
|
||||
vector<string> t_rgb;
|
||||
string depth;
|
||||
bool t_to_256 = Config::getB("lowcolor");
|
||||
|
@ -372,7 +373,7 @@ namespace Theme {
|
|||
|
||||
//* Load a .theme file from disk
|
||||
auto loadFile(const string& filename) {
|
||||
unordered_flat_map<string, string> theme_out;
|
||||
ankerl::unordered_dense::map<string, string> theme_out;
|
||||
const fs::path filepath = filename;
|
||||
if (not fs::exists(filepath))
|
||||
return Default_theme;
|
||||
|
|
|
@ -22,12 +22,12 @@ tab-size = 4
|
|||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <robin_hood.h>
|
||||
|
||||
#include "ankerl/unordered_dense.h"
|
||||
|
||||
using std::array;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using robin_hood::unordered_flat_map;
|
||||
|
||||
namespace Theme {
|
||||
extern std::filesystem::path theme_dir;
|
||||
|
@ -54,9 +54,9 @@ namespace Theme {
|
|||
//* Set current theme from current "color_theme" value in config
|
||||
void setTheme();
|
||||
|
||||
extern unordered_flat_map<string, string> colors;
|
||||
extern unordered_flat_map<string, array<int, 3>> rgbs;
|
||||
extern unordered_flat_map<string, array<string, 101>> gradients;
|
||||
extern ankerl::unordered_dense::map<string, string> colors;
|
||||
extern ankerl::unordered_dense::map<string, array<int, 3>> rgbs;
|
||||
extern ankerl::unordered_dense::map<string, array<string, 101>> gradients;
|
||||
|
||||
//* Return escape code for color <name>
|
||||
inline const string& c(const string& name) { return colors.at(name); }
|
||||
|
|
|
@ -30,7 +30,7 @@ tab-size = 4
|
|||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "robin_hood.h"
|
||||
#include "ankerl/unordered_dense.h"
|
||||
#include "widechar_width.hpp"
|
||||
#include "btop_shared.hpp"
|
||||
#include "btop_tools.hpp"
|
||||
|
@ -43,7 +43,6 @@ using std::flush;
|
|||
using std::max;
|
||||
using std::string_view;
|
||||
using std::to_string;
|
||||
using robin_hood::unordered_flat_map;
|
||||
|
||||
using namespace std::literals; // to use operator""s
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@ tab-size = 4
|
|||
#define HOST_NAME_MAX 64
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "ankerl/unordered_dense.h"
|
||||
#define FMT_HEADER_ONLY
|
||||
#include "fmt/core.h"
|
||||
#include "fmt/format.h"
|
||||
|
|
|
@ -58,6 +58,9 @@ tab-size = 4
|
|||
#include <regex>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "ankerl/unordered_dense.h"
|
||||
|
||||
#include "../btop_config.hpp"
|
||||
#include "../btop_shared.hpp"
|
||||
|
@ -98,7 +101,7 @@ namespace Cpu {
|
|||
|
||||
string cpu_sensor;
|
||||
vector<string> core_sensors;
|
||||
unordered_flat_map<int, int> core_mapping;
|
||||
ankerl::unordered_dense::map<int, int> core_mapping;
|
||||
} // namespace Cpu
|
||||
|
||||
namespace Mem {
|
||||
|
@ -204,7 +207,7 @@ namespace Cpu {
|
|||
|
||||
const array<string, 10> time_names = {"user", "nice", "system", "idle"};
|
||||
|
||||
unordered_flat_map<string, long long> cpu_old = {
|
||||
ankerl::unordered_dense::map<string, long long> cpu_old = {
|
||||
{"totals", 0},
|
||||
{"idles", 0},
|
||||
{"user", 0},
|
||||
|
@ -323,8 +326,8 @@ namespace Cpu {
|
|||
return std::to_string(freq / 1000.0 ).substr(0, 3); // seems to be in MHz
|
||||
}
|
||||
|
||||
auto get_core_mapping() -> unordered_flat_map<int, int> {
|
||||
unordered_flat_map<int, int> core_map;
|
||||
auto get_core_mapping() -> ankerl::unordered_dense::map<int, int> {
|
||||
ankerl::unordered_dense::map<int, int> core_map;
|
||||
if (cpu_temp_only) return core_map;
|
||||
|
||||
for (long i = 0; i < Shared::coreCount; i++) {
|
||||
|
@ -557,7 +560,7 @@ namespace Mem {
|
|||
}
|
||||
}
|
||||
|
||||
void collect_disk(unordered_flat_map<string, disk_info> &disks, unordered_flat_map<string, string> &mapping) {
|
||||
void collect_disk(ankerl::unordered_dense::map<string, disk_info> &disks, ankerl::unordered_dense::map<string, string> &mapping) {
|
||||
// this bit is for 'regular' mounts
|
||||
static struct statinfo cur;
|
||||
long double etime = 0;
|
||||
|
@ -691,7 +694,7 @@ namespace Mem {
|
|||
}
|
||||
|
||||
if (show_disks) {
|
||||
unordered_flat_map<string, string> mapping; // keep mapping from device -> mountpoint, since IOKit doesn't give us the mountpoint
|
||||
ankerl::unordered_dense::map<string, string> mapping; // keep mapping from device -> mountpoint, since IOKit doesn't give us the mountpoint
|
||||
double uptime = system_uptime();
|
||||
auto &disks_filter = Config::getS("disks_filter");
|
||||
bool filter_exclude = false;
|
||||
|
@ -807,13 +810,13 @@ namespace Mem {
|
|||
} // namespace Mem
|
||||
|
||||
namespace Net {
|
||||
unordered_flat_map<string, net_info> current_net;
|
||||
ankerl::unordered_dense::map<string, net_info> current_net;
|
||||
net_info empty_net = {};
|
||||
vector<string> interfaces;
|
||||
string selected_iface;
|
||||
int errors = 0;
|
||||
unordered_flat_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
|
||||
unordered_flat_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
|
||||
ankerl::unordered_dense::map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
|
||||
ankerl::unordered_dense::map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
|
||||
bool rescale = true;
|
||||
uint64_t timestamp = 0;
|
||||
|
||||
|
@ -892,7 +895,7 @@ namespace Net {
|
|||
} //else, ignoring family==AF_LINK (see man 3 getifaddrs)
|
||||
}
|
||||
|
||||
unordered_flat_map<string, std::tuple<uint64_t, uint64_t>> ifstats;
|
||||
ankerl::unordered_dense::map<string, std::tuple<uint64_t, uint64_t>> ifstats;
|
||||
int mib[] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0};
|
||||
size_t len;
|
||||
if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) {
|
||||
|
@ -966,7 +969,7 @@ namespace Net {
|
|||
else
|
||||
it++;
|
||||
}
|
||||
net.compact();
|
||||
net.rehash(0);
|
||||
}
|
||||
|
||||
timestamp = new_timestamp;
|
||||
|
@ -1037,7 +1040,7 @@ namespace Net {
|
|||
namespace Proc {
|
||||
|
||||
vector<proc_info> current_procs;
|
||||
unordered_flat_map<string, string> uid_user;
|
||||
ankerl::unordered_dense::map<string, string> uid_user;
|
||||
string current_sort;
|
||||
string current_filter;
|
||||
bool current_rev = false;
|
||||
|
|
|
@ -17,7 +17,6 @@ tab-size = 4
|
|||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <robin_hood.h>
|
||||
#include <fstream>
|
||||
#include <ranges>
|
||||
#include <cmath>
|
||||
|
@ -30,6 +29,7 @@ tab-size = 4
|
|||
#include <arpa/inet.h> // for inet_ntop()
|
||||
#include <filesystem>
|
||||
#include <future>
|
||||
#include <utility>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#if defined(RSMI_STATIC)
|
||||
|
@ -40,6 +40,8 @@ tab-size = 4
|
|||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include "ankerl/unordered_dense.h"
|
||||
|
||||
#include "../btop_shared.hpp"
|
||||
#include "../btop_config.hpp"
|
||||
#include "../btop_tools.hpp"
|
||||
|
@ -94,10 +96,10 @@ namespace Cpu {
|
|||
int64_t crit{}; // defaults to 0
|
||||
};
|
||||
|
||||
unordered_flat_map<string, Sensor> found_sensors;
|
||||
ankerl::unordered_dense::map<string, Sensor> found_sensors;
|
||||
string cpu_sensor;
|
||||
vector<string> core_sensors;
|
||||
unordered_flat_map<int, int> core_mapping;
|
||||
ankerl::unordered_dense::map<int, int> core_mapping;
|
||||
}
|
||||
|
||||
namespace Gpu {
|
||||
|
@ -298,7 +300,7 @@ namespace Cpu {
|
|||
"irq"s, "softirq"s, "steal"s, "guest"s, "guest_nice"s
|
||||
};
|
||||
|
||||
unordered_flat_map<string, long long> cpu_old = {
|
||||
ankerl::unordered_dense::map<string, long long> cpu_old = {
|
||||
{"totals", 0},
|
||||
{"idles", 0},
|
||||
{"user", 0},
|
||||
|
@ -595,8 +597,8 @@ namespace Cpu {
|
|||
return cpuhz;
|
||||
}
|
||||
|
||||
auto get_core_mapping() -> unordered_flat_map<int, int> {
|
||||
unordered_flat_map<int, int> core_map;
|
||||
auto get_core_mapping() -> ankerl::unordered_dense::map<int, int> {
|
||||
ankerl::unordered_dense::map<int, int> core_map;
|
||||
if (cpu_temp_only) return core_map;
|
||||
|
||||
//? Try to get core mapping from /proc/cpuinfo
|
||||
|
@ -669,7 +671,7 @@ namespace Cpu {
|
|||
auto get_battery() -> tuple<int, long, string> {
|
||||
if (not has_battery) return {0, 0, ""};
|
||||
static string auto_sel;
|
||||
static unordered_flat_map<string, battery> batteries;
|
||||
static ankerl::unordered_dense::map<string, battery> batteries;
|
||||
|
||||
//? Get paths to needed files and check for valid values on first run
|
||||
if (batteries.empty() and has_battery) {
|
||||
|
@ -1613,7 +1615,7 @@ namespace Mem {
|
|||
auto only_physical = Config::getB("only_physical");
|
||||
auto zfs_hide_datasets = Config::getB("zfs_hide_datasets");
|
||||
auto& disks = mem.disks;
|
||||
static unordered_flat_map<string, future<pair<disk_info, int>>> disks_stats_promises;
|
||||
static ankerl::unordered_dense::map<string, future<pair<disk_info, int>>> disks_stats_promises;
|
||||
ifstream diskread;
|
||||
|
||||
vector<string> filter;
|
||||
|
@ -2045,13 +2047,13 @@ namespace Mem {
|
|||
}
|
||||
|
||||
namespace Net {
|
||||
unordered_flat_map<string, net_info> current_net;
|
||||
ankerl::unordered_dense::map<string, net_info> current_net;
|
||||
net_info empty_net = {};
|
||||
vector<string> interfaces;
|
||||
string selected_iface;
|
||||
int errors{}; // defaults to 0
|
||||
unordered_flat_map<string, uint64_t> graph_max = { {"download", {}}, {"upload", {}} };
|
||||
unordered_flat_map<string, array<int, 2>> max_count = { {"download", {}}, {"upload", {}} };
|
||||
ankerl::unordered_dense::map<string, uint64_t> graph_max = { {"download", {}}, {"upload", {}} };
|
||||
ankerl::unordered_dense::map<string, array<int, 2>> max_count = { {"download", {}}, {"upload", {}} };
|
||||
bool rescale{true};
|
||||
uint64_t timestamp{}; // defaults to 0
|
||||
|
||||
|
@ -2190,7 +2192,7 @@ namespace Net {
|
|||
else
|
||||
it++;
|
||||
}
|
||||
net.compact();
|
||||
net.rehash(0);
|
||||
}
|
||||
|
||||
timestamp = new_timestamp;
|
||||
|
@ -2260,7 +2262,7 @@ namespace Net {
|
|||
namespace Proc {
|
||||
|
||||
vector<proc_info> current_procs;
|
||||
unordered_flat_map<string, string> uid_user;
|
||||
ankerl::unordered_dense::map<string, string> uid_user;
|
||||
string current_sort;
|
||||
string current_filter;
|
||||
bool current_rev{}; // defaults to false
|
||||
|
@ -2275,7 +2277,7 @@ namespace Proc {
|
|||
|
||||
detail_container detailed;
|
||||
constexpr size_t KTHREADD = 2;
|
||||
static robin_hood::unordered_set<size_t> kernels_procs = {KTHREADD};
|
||||
static ankerl::unordered_dense::set<size_t> kernels_procs = {KTHREADD};
|
||||
|
||||
//* Get detailed info for selected process
|
||||
void _collect_details(const size_t pid, const uint64_t uptime, vector<proc_info>& procs) {
|
||||
|
|
|
@ -51,6 +51,9 @@ tab-size = 4
|
|||
#include <ranges>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "ankerl/unordered_dense.h"
|
||||
|
||||
#include "../btop_config.hpp"
|
||||
#include "../btop_shared.hpp"
|
||||
|
@ -95,7 +98,7 @@ namespace Cpu {
|
|||
|
||||
string cpu_sensor;
|
||||
vector<string> core_sensors;
|
||||
unordered_flat_map<int, int> core_mapping;
|
||||
ankerl::unordered_dense::map<int, int> core_mapping;
|
||||
} // namespace Cpu
|
||||
|
||||
namespace Mem {
|
||||
|
@ -191,7 +194,7 @@ namespace Cpu {
|
|||
|
||||
const array<string, 10> time_names = {"user", "nice", "system", "idle"};
|
||||
|
||||
unordered_flat_map<string, long long> cpu_old = {
|
||||
ankerl::unordered_dense::map<string, long long> cpu_old = {
|
||||
{"totals", 0},
|
||||
{"idles", 0},
|
||||
{"user", 0},
|
||||
|
@ -329,8 +332,8 @@ namespace Cpu {
|
|||
return std::to_string(freq / 1000.0 / 1000.0 / 1000.0).substr(0, 3);
|
||||
}
|
||||
|
||||
auto get_core_mapping() -> unordered_flat_map<int, int> {
|
||||
unordered_flat_map<int, int> core_map;
|
||||
auto get_core_mapping() -> ankerl::unordered_dense::map<int, int> {
|
||||
ankerl::unordered_dense::map<int, int> core_map;
|
||||
if (cpu_temp_only) return core_map;
|
||||
|
||||
natural_t cpu_count;
|
||||
|
@ -591,7 +594,7 @@ namespace Mem {
|
|||
io_object_t &object;
|
||||
};
|
||||
|
||||
void collect_disk(unordered_flat_map<string, disk_info> &disks, unordered_flat_map<string, string> &mapping) {
|
||||
void collect_disk(ankerl::unordered_dense::map<string, disk_info> &disks, ankerl::unordered_dense::map<string, string> &mapping) {
|
||||
io_registry_entry_t drive;
|
||||
io_iterator_t drive_list;
|
||||
|
||||
|
@ -708,7 +711,7 @@ namespace Mem {
|
|||
}
|
||||
|
||||
if (show_disks) {
|
||||
unordered_flat_map<string, string> mapping; // keep mapping from device -> mountpoint, since IOKit doesn't give us the mountpoint
|
||||
ankerl::unordered_dense::map<string, string> mapping; // keep mapping from device -> mountpoint, since IOKit doesn't give us the mountpoint
|
||||
double uptime = system_uptime();
|
||||
auto &disks_filter = Config::getS("disks_filter");
|
||||
bool filter_exclude = false;
|
||||
|
@ -821,13 +824,13 @@ namespace Mem {
|
|||
} // namespace Mem
|
||||
|
||||
namespace Net {
|
||||
unordered_flat_map<string, net_info> current_net;
|
||||
ankerl::unordered_dense::map<string, net_info> current_net;
|
||||
net_info empty_net = {};
|
||||
vector<string> interfaces;
|
||||
string selected_iface;
|
||||
int errors = 0;
|
||||
unordered_flat_map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
|
||||
unordered_flat_map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
|
||||
ankerl::unordered_dense::map<string, uint64_t> graph_max = {{"download", {}}, {"upload", {}}};
|
||||
ankerl::unordered_dense::map<string, array<int, 2>> max_count = {{"download", {}}, {"upload", {}}};
|
||||
bool rescale = true;
|
||||
uint64_t timestamp = 0;
|
||||
|
||||
|
@ -904,7 +907,7 @@ namespace Net {
|
|||
} // else, ignoring family==AF_LINK (see man 3 getifaddrs)
|
||||
}
|
||||
|
||||
unordered_flat_map<string, std::tuple<uint64_t, uint64_t>> ifstats;
|
||||
ankerl::unordered_dense::map<string, std::tuple<uint64_t, uint64_t>> ifstats;
|
||||
int mib[] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST2, 0};
|
||||
size_t len;
|
||||
if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) {
|
||||
|
@ -978,7 +981,7 @@ namespace Net {
|
|||
else
|
||||
it++;
|
||||
}
|
||||
net.compact();
|
||||
net.rehash(0);
|
||||
}
|
||||
|
||||
timestamp = new_timestamp;
|
||||
|
@ -1049,7 +1052,7 @@ namespace Net {
|
|||
namespace Proc {
|
||||
|
||||
vector<proc_info> current_procs;
|
||||
unordered_flat_map<string, string> uid_user;
|
||||
ankerl::unordered_dense::map<string, string> uid_user;
|
||||
string current_sort;
|
||||
string current_filter;
|
||||
bool current_rev = false;
|
||||
|
|
Loading…
Reference in New Issue