archive_r_ruby 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{LICENSE → LICENSE.txt} +77 -77
- data/README.md +103 -103
- data/ext/archive_r/Makefile +48 -45
- data/ext/archive_r/archive_r-x64-mingw-ucrt.def +2 -0
- data/ext/archive_r/archive_r_ext.cc +1106 -1106
- data/ext/archive_r/archive_r_ext.o +0 -0
- data/ext/archive_r/extconf.rb +120 -120
- data/ext/archive_r/mkmf.log +23 -18
- data/ext/archive_r/vendor/archive_r/LICENSE.txt +77 -77
- data/ext/archive_r/vendor/archive_r/include/archive_r/data_stream.h +52 -52
- data/ext/archive_r/vendor/archive_r/include/archive_r/entry.h +166 -166
- data/ext/archive_r/vendor/archive_r/include/archive_r/entry_fault.h +34 -34
- data/ext/archive_r/vendor/archive_r/include/archive_r/entry_metadata.h +56 -56
- data/ext/archive_r/vendor/archive_r/include/archive_r/multi_volume_stream_base.h +46 -46
- data/ext/archive_r/vendor/archive_r/include/archive_r/path_hierarchy.h +109 -109
- data/ext/archive_r/vendor/archive_r/include/archive_r/path_hierarchy_utils.h +37 -37
- data/ext/archive_r/vendor/archive_r/include/archive_r/platform_compat.h +19 -19
- data/ext/archive_r/vendor/archive_r/include/archive_r/traverser.h +122 -122
- data/ext/archive_r/vendor/archive_r/src/archive_stack_cursor.cc +330 -330
- data/ext/archive_r/vendor/archive_r/src/archive_stack_cursor.h +97 -97
- data/ext/archive_r/vendor/archive_r/src/archive_stack_orchestrator.cc +162 -162
- data/ext/archive_r/vendor/archive_r/src/archive_stack_orchestrator.h +54 -54
- data/ext/archive_r/vendor/archive_r/src/archive_type.cc +552 -552
- data/ext/archive_r/vendor/archive_r/src/archive_type.h +77 -77
- data/ext/archive_r/vendor/archive_r/src/data_stream.cc +35 -35
- data/ext/archive_r/vendor/archive_r/src/entry.cc +253 -253
- data/ext/archive_r/vendor/archive_r/src/entry_fault.cc +26 -26
- data/ext/archive_r/vendor/archive_r/src/entry_fault_error.cc +54 -54
- data/ext/archive_r/vendor/archive_r/src/entry_fault_error.h +32 -32
- data/ext/archive_r/vendor/archive_r/src/entry_impl.h +57 -57
- data/ext/archive_r/vendor/archive_r/src/multi_volume_manager.cc +81 -81
- data/ext/archive_r/vendor/archive_r/src/multi_volume_manager.h +41 -41
- data/ext/archive_r/vendor/archive_r/src/multi_volume_stream_base.cc +199 -199
- data/ext/archive_r/vendor/archive_r/src/path_hierarchy.cc +151 -151
- data/ext/archive_r/vendor/archive_r/src/path_hierarchy_utils.cc +304 -304
- data/ext/archive_r/vendor/archive_r/src/simple_profiler.h +120 -120
- data/ext/archive_r/vendor/archive_r/src/system_file_stream.cc +295 -295
- data/ext/archive_r/vendor/archive_r/src/system_file_stream.h +46 -46
- data/ext/archive_r/vendor/archive_r/src/traverser.cc +314 -314
- data/lib/archive_r.rb +105 -105
- metadata +11 -8
- data/ext/archive_r/archive_r.bundle +0 -0
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
// Copyright (c) 2025 archive_r Team
|
|
3
|
-
|
|
4
|
-
#pragma once
|
|
5
|
-
#include <string>
|
|
6
|
-
|
|
7
|
-
#include <chrono>
|
|
8
|
-
#include <iostream>
|
|
9
|
-
#include <map>
|
|
10
|
-
#include <vector>
|
|
11
|
-
#include <algorithm>
|
|
12
|
-
#include <iomanip>
|
|
13
|
-
#include <mutex>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
namespace archive_r {
|
|
17
|
-
namespace internal {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class SimpleProfiler {
|
|
22
|
-
public:
|
|
23
|
-
static SimpleProfiler& instance() {
|
|
24
|
-
static SimpleProfiler inst;
|
|
25
|
-
return inst;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
~SimpleProfiler() {
|
|
29
|
-
report();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
void start(const std::string& name) {
|
|
33
|
-
std::lock_guard<std::mutex> lock(mutex_);
|
|
34
|
-
auto now = std::chrono::high_resolution_clock::now();
|
|
35
|
-
start_times_[name] = now;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
void stop(const std::string& name) {
|
|
39
|
-
std::lock_guard<std::mutex> lock(mutex_);
|
|
40
|
-
auto now = std::chrono::high_resolution_clock::now();
|
|
41
|
-
auto it = start_times_.find(name);
|
|
42
|
-
if (it != start_times_.end()) {
|
|
43
|
-
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(now - it->second).count();
|
|
44
|
-
durations_[name] += duration;
|
|
45
|
-
counts_[name]++;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
void report() {
|
|
50
|
-
std::lock_guard<std::mutex> lock(mutex_);
|
|
51
|
-
if (durations_.empty()) return;
|
|
52
|
-
|
|
53
|
-
std::cout << "\n=== Profiling Report (archive_r::internal) ===" << std::endl;
|
|
54
|
-
std::vector<std::pair<std::string, long long>> sorted_durations;
|
|
55
|
-
for (const auto& pair : durations_) {
|
|
56
|
-
sorted_durations.push_back(pair);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
std::sort(sorted_durations.begin(), sorted_durations.end(),
|
|
60
|
-
[](const auto& a, const auto& b) { return a.second > b.second; });
|
|
61
|
-
|
|
62
|
-
std::cout << std::left << std::setw(40) << "Name"
|
|
63
|
-
<< std::right << std::setw(15) << "Total (ms)"
|
|
64
|
-
<< std::setw(10) << "Count"
|
|
65
|
-
<< std::setw(15) << "Avg (us)" << std::endl;
|
|
66
|
-
std::cout << std::string(80, '-') << std::endl;
|
|
67
|
-
|
|
68
|
-
for (const auto& pair : sorted_durations) {
|
|
69
|
-
const auto& name = pair.first;
|
|
70
|
-
long long total_ns = pair.second;
|
|
71
|
-
long long count = counts_[name];
|
|
72
|
-
double avg_ns = count > 0 ? (double)total_ns / count : 0;
|
|
73
|
-
|
|
74
|
-
std::cout << std::left << std::setw(40) << name
|
|
75
|
-
<< std::right << std::setw(15) << std::fixed << std::setprecision(3) << total_ns / 1000000.0
|
|
76
|
-
<< std::setw(10) << count
|
|
77
|
-
<< std::setw(15) << std::fixed << std::setprecision(3) << avg_ns / 1000.0
|
|
78
|
-
<< std::endl;
|
|
79
|
-
}
|
|
80
|
-
std::cout << "==============================================\n" << std::endl;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
void reset() {
|
|
84
|
-
std::lock_guard<std::mutex> lock(mutex_);
|
|
85
|
-
start_times_.clear();
|
|
86
|
-
durations_.clear();
|
|
87
|
-
counts_.clear();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private:
|
|
91
|
-
std::map<std::string, std::chrono::high_resolution_clock::time_point> start_times_;
|
|
92
|
-
std::map<std::string, long long> durations_;
|
|
93
|
-
std::map<std::string, long long> counts_;
|
|
94
|
-
std::mutex mutex_;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
class ScopedTimer {
|
|
98
|
-
public:
|
|
99
|
-
ScopedTimer(const std::string& name) : name_(name) {
|
|
100
|
-
SimpleProfiler::instance().start(name_);
|
|
101
|
-
}
|
|
102
|
-
~ScopedTimer() {
|
|
103
|
-
SimpleProfiler::instance().stop(name_);
|
|
104
|
-
}
|
|
105
|
-
private:
|
|
106
|
-
std::string name_;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
} // namespace internal
|
|
110
|
-
} // namespace archive_r
|
|
111
|
-
|
|
112
|
-
#ifdef ARCHIVE_R_SIMPLE_PROFILER_DISABLED
|
|
113
|
-
#define ARCHIVE_R_PROFILE(name) ((void)0)
|
|
114
|
-
#else
|
|
115
|
-
#define ARCHIVE_R_PROFILE(name) ::archive_r::internal::ScopedTimer ARCHIVE_R_PROFILE_UNIQUE_NAME(name)(name)
|
|
116
|
-
#endif
|
|
117
|
-
|
|
118
|
-
#define ARCHIVE_R_PROFILE_UNIQUE_NAME(name) ARCHIVE_R_PROFILE_CONCAT(_archive_r_profiler_scope_, __COUNTER__)
|
|
119
|
-
#define ARCHIVE_R_PROFILE_CONCAT(a, b) ARCHIVE_R_PROFILE_CONCAT_INNER(a, b)
|
|
120
|
-
#define ARCHIVE_R_PROFILE_CONCAT_INNER(a, b) a##b
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2025 archive_r Team
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
#include <chrono>
|
|
8
|
+
#include <iostream>
|
|
9
|
+
#include <map>
|
|
10
|
+
#include <vector>
|
|
11
|
+
#include <algorithm>
|
|
12
|
+
#include <iomanip>
|
|
13
|
+
#include <mutex>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
namespace archive_r {
|
|
17
|
+
namespace internal {
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class SimpleProfiler {
|
|
22
|
+
public:
|
|
23
|
+
static SimpleProfiler& instance() {
|
|
24
|
+
static SimpleProfiler inst;
|
|
25
|
+
return inst;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
~SimpleProfiler() {
|
|
29
|
+
report();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
void start(const std::string& name) {
|
|
33
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
|
34
|
+
auto now = std::chrono::high_resolution_clock::now();
|
|
35
|
+
start_times_[name] = now;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
void stop(const std::string& name) {
|
|
39
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
|
40
|
+
auto now = std::chrono::high_resolution_clock::now();
|
|
41
|
+
auto it = start_times_.find(name);
|
|
42
|
+
if (it != start_times_.end()) {
|
|
43
|
+
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(now - it->second).count();
|
|
44
|
+
durations_[name] += duration;
|
|
45
|
+
counts_[name]++;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void report() {
|
|
50
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
|
51
|
+
if (durations_.empty()) return;
|
|
52
|
+
|
|
53
|
+
std::cout << "\n=== Profiling Report (archive_r::internal) ===" << std::endl;
|
|
54
|
+
std::vector<std::pair<std::string, long long>> sorted_durations;
|
|
55
|
+
for (const auto& pair : durations_) {
|
|
56
|
+
sorted_durations.push_back(pair);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
std::sort(sorted_durations.begin(), sorted_durations.end(),
|
|
60
|
+
[](const auto& a, const auto& b) { return a.second > b.second; });
|
|
61
|
+
|
|
62
|
+
std::cout << std::left << std::setw(40) << "Name"
|
|
63
|
+
<< std::right << std::setw(15) << "Total (ms)"
|
|
64
|
+
<< std::setw(10) << "Count"
|
|
65
|
+
<< std::setw(15) << "Avg (us)" << std::endl;
|
|
66
|
+
std::cout << std::string(80, '-') << std::endl;
|
|
67
|
+
|
|
68
|
+
for (const auto& pair : sorted_durations) {
|
|
69
|
+
const auto& name = pair.first;
|
|
70
|
+
long long total_ns = pair.second;
|
|
71
|
+
long long count = counts_[name];
|
|
72
|
+
double avg_ns = count > 0 ? (double)total_ns / count : 0;
|
|
73
|
+
|
|
74
|
+
std::cout << std::left << std::setw(40) << name
|
|
75
|
+
<< std::right << std::setw(15) << std::fixed << std::setprecision(3) << total_ns / 1000000.0
|
|
76
|
+
<< std::setw(10) << count
|
|
77
|
+
<< std::setw(15) << std::fixed << std::setprecision(3) << avg_ns / 1000.0
|
|
78
|
+
<< std::endl;
|
|
79
|
+
}
|
|
80
|
+
std::cout << "==============================================\n" << std::endl;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
void reset() {
|
|
84
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
|
85
|
+
start_times_.clear();
|
|
86
|
+
durations_.clear();
|
|
87
|
+
counts_.clear();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private:
|
|
91
|
+
std::map<std::string, std::chrono::high_resolution_clock::time_point> start_times_;
|
|
92
|
+
std::map<std::string, long long> durations_;
|
|
93
|
+
std::map<std::string, long long> counts_;
|
|
94
|
+
std::mutex mutex_;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
class ScopedTimer {
|
|
98
|
+
public:
|
|
99
|
+
ScopedTimer(const std::string& name) : name_(name) {
|
|
100
|
+
SimpleProfiler::instance().start(name_);
|
|
101
|
+
}
|
|
102
|
+
~ScopedTimer() {
|
|
103
|
+
SimpleProfiler::instance().stop(name_);
|
|
104
|
+
}
|
|
105
|
+
private:
|
|
106
|
+
std::string name_;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
} // namespace internal
|
|
110
|
+
} // namespace archive_r
|
|
111
|
+
|
|
112
|
+
#ifdef ARCHIVE_R_SIMPLE_PROFILER_DISABLED
|
|
113
|
+
#define ARCHIVE_R_PROFILE(name) ((void)0)
|
|
114
|
+
#else
|
|
115
|
+
#define ARCHIVE_R_PROFILE(name) ::archive_r::internal::ScopedTimer ARCHIVE_R_PROFILE_UNIQUE_NAME(name)(name)
|
|
116
|
+
#endif
|
|
117
|
+
|
|
118
|
+
#define ARCHIVE_R_PROFILE_UNIQUE_NAME(name) ARCHIVE_R_PROFILE_CONCAT(_archive_r_profiler_scope_, __COUNTER__)
|
|
119
|
+
#define ARCHIVE_R_PROFILE_CONCAT(a, b) ARCHIVE_R_PROFILE_CONCAT_INNER(a, b)
|
|
120
|
+
#define ARCHIVE_R_PROFILE_CONCAT_INNER(a, b) a##b
|