Skip to content

Commit 3775a81

Browse files
committed
formatted code
1 parent 0a1bf11 commit 3775a81

16 files changed

+105
-0
lines changed

.clang-format

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
BasedOnStyle: LLVM
22
SortIncludes: false
3+
SeparateDefinitionBlocks: Always
4+
MaxEmptyLinesToKeep: 1

benchmarks/apple_arm_events.h

+6
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ struct performance_counters {
5252
double branches;
5353
double missed_branches;
5454
double instructions;
55+
5556
performance_counters(uint64_t c, uint64_t b, uint64_t m, uint64_t i)
5657
: cycles(c), branches(b), missed_branches(m), instructions(i) {}
58+
5759
performance_counters(double c, double b, double m, double i)
5860
: cycles(c), branches(b), missed_branches(m), instructions(i) {}
61+
5962
performance_counters(double init)
6063
: cycles(init), branches(init), missed_branches(init),
6164
instructions(init) {}
@@ -67,6 +70,7 @@ struct performance_counters {
6770
instructions -= other.instructions;
6871
return *this;
6972
}
73+
7074
inline performance_counters &min(const performance_counters &other) {
7175
cycles = other.cycles < cycles ? other.cycles : cycles;
7276
branches = other.branches < branches ? other.branches : branches;
@@ -77,6 +81,7 @@ struct performance_counters {
7781
other.instructions < instructions ? other.instructions : instructions;
7882
return *this;
7983
}
84+
8085
inline performance_counters &operator+=(const performance_counters &other) {
8186
cycles += other.cycles;
8287
branches += other.branches;
@@ -920,6 +925,7 @@ static int kdebug_wait(usize timeout_ms, bool *suc) {
920925
// -----------------------------------------------------------------------------
921926

922927
#define EVENT_NAME_MAX 8
928+
923929
typedef struct {
924930
const char *alias; /// name for print
925931
const char *names[EVENT_NAME_MAX]; /// name from pmc db

benchmarks/event_counter.h

+20
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424
struct event_count {
2525
std::chrono::duration<double> elapsed;
2626
std::vector<unsigned long long> event_counts;
27+
2728
event_count() : elapsed(0), event_counts{0, 0, 0, 0, 0} {}
29+
2830
event_count(const std::chrono::duration<double> _elapsed,
2931
const std::vector<unsigned long long> _event_counts)
3032
: elapsed(_elapsed), event_counts(_event_counts) {}
33+
3134
event_count(const event_count &other)
3235
: elapsed(other.elapsed), event_counts(other.event_counts) {}
3336

@@ -42,18 +45,23 @@ struct event_count {
4245
double elapsed_sec() const {
4346
return std::chrono::duration<double>(elapsed).count();
4447
}
48+
4549
double elapsed_ns() const {
4650
return std::chrono::duration<double, std::nano>(elapsed).count();
4751
}
52+
4853
double cycles() const {
4954
return static_cast<double>(event_counts[CPU_CYCLES]);
5055
}
56+
5157
double instructions() const {
5258
return static_cast<double>(event_counts[INSTRUCTIONS]);
5359
}
60+
5461
double branches() const {
5562
return static_cast<double>(event_counts[BRANCHES]);
5663
}
64+
5765
double missed_branches() const {
5866
return static_cast<double>(event_counts[MISSED_BRANCHES]);
5967
}
@@ -63,6 +71,7 @@ struct event_count {
6371
this->event_counts = other.event_counts;
6472
return *this;
6573
}
74+
6675
event_count operator+(const event_count &other) const {
6776
return event_count(elapsed + other.elapsed,
6877
{
@@ -98,10 +107,15 @@ struct event_aggregate {
98107
}
99108

100109
double elapsed_sec() const { return total.elapsed_sec() / iterations; }
110+
101111
double elapsed_ns() const { return total.elapsed_ns() / iterations; }
112+
102113
double cycles() const { return total.cycles() / iterations; }
114+
103115
double instructions() const { return total.instructions() / iterations; }
116+
104117
double branches() const { return total.branches() / iterations; }
118+
105119
double missed_branches() const {
106120
return total.missed_branches() / iterations;
107121
}
@@ -113,18 +127,23 @@ struct event_collector {
113127

114128
#if defined(__linux__)
115129
LinuxEvents<PERF_TYPE_HARDWARE> linux_events;
130+
116131
event_collector()
117132
: linux_events(std::vector<int>{
118133
PERF_COUNT_HW_CPU_CYCLES, PERF_COUNT_HW_INSTRUCTIONS,
119134
PERF_COUNT_HW_BRANCH_INSTRUCTIONS, // Retired branch instructions
120135
PERF_COUNT_HW_BRANCH_MISSES}) {}
136+
121137
bool has_events() { return linux_events.is_working(); }
122138
#elif __APPLE__ && __aarch64__
123139
performance_counters diff;
140+
124141
event_collector() : diff(0) { setup_performance_counters(); }
142+
125143
bool has_events() { return setup_performance_counters(); }
126144
#else
127145
event_collector() {}
146+
128147
bool has_events() { return false; }
129148
#endif
130149

@@ -138,6 +157,7 @@ struct event_collector {
138157
#endif
139158
start_clock = std::chrono::steady_clock::now();
140159
}
160+
141161
inline event_count &end() {
142162
const auto end_clock = std::chrono::steady_clock::now();
143163
#if defined(__linux)

include/fast_float/bigint.h

+14
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ template <uint16_t size> struct stackvec {
5757
FASTFLOAT_DEBUG_ASSERT(index < length);
5858
return data[index];
5959
}
60+
6061
FASTFLOAT_CONSTEXPR14 const limb &operator[](size_t index) const noexcept {
6162
FASTFLOAT_DEBUG_ASSERT(index < length);
6263
return data[index];
6364
}
65+
6466
// index from the end of the container
6567
FASTFLOAT_CONSTEXPR14 const limb &rindex(size_t index) const noexcept {
6668
FASTFLOAT_DEBUG_ASSERT(index < length);
@@ -72,14 +74,19 @@ template <uint16_t size> struct stackvec {
7274
FASTFLOAT_CONSTEXPR14 void set_len(size_t len) noexcept {
7375
length = uint16_t(len);
7476
}
77+
7578
constexpr size_t len() const noexcept { return length; }
79+
7680
constexpr bool is_empty() const noexcept { return length == 0; }
81+
7782
constexpr size_t capacity() const noexcept { return size; }
83+
7884
// append item to vector, without bounds checking
7985
FASTFLOAT_CONSTEXPR14 void push_unchecked(limb value) noexcept {
8086
data[length] = value;
8187
length++;
8288
}
89+
8390
// append item to vector, returning if item was added
8491
FASTFLOAT_CONSTEXPR14 bool try_push(limb value) noexcept {
8592
if (len() < capacity()) {
@@ -89,12 +96,14 @@ template <uint16_t size> struct stackvec {
8996
return false;
9097
}
9198
}
99+
92100
// add items to the vector, from a span, without bounds checking
93101
FASTFLOAT_CONSTEXPR20 void extend_unchecked(limb_span s) noexcept {
94102
limb *ptr = data + length;
95103
std::copy_n(s.ptr, s.len(), ptr);
96104
set_len(len() + s.len());
97105
}
106+
98107
// try to add items to the vector, returning if items were added
99108
FASTFLOAT_CONSTEXPR20 bool try_extend(limb_span s) noexcept {
100109
if (len() + s.len() <= capacity()) {
@@ -104,6 +113,7 @@ template <uint16_t size> struct stackvec {
104113
return false;
105114
}
106115
}
116+
107117
// resize the vector, without bounds checking
108118
// if the new size is longer than the vector, assign value to each
109119
// appended item.
@@ -119,6 +129,7 @@ template <uint16_t size> struct stackvec {
119129
set_len(new_len);
120130
}
121131
}
132+
122133
// try to resize the vector, returning if the vector was resized.
123134
FASTFLOAT_CONSTEXPR20 bool try_resize(size_t new_len, limb value) noexcept {
124135
if (new_len > capacity()) {
@@ -128,6 +139,7 @@ template <uint16_t size> struct stackvec {
128139
return true;
129140
}
130141
}
142+
131143
// check if any limbs are non-zero after the given index.
132144
// this needs to be done in reverse order, since the index
133145
// is relative to the most significant limbs.
@@ -140,6 +152,7 @@ template <uint16_t size> struct stackvec {
140152
}
141153
return false;
142154
}
155+
143156
// normalize the big integer, so most-significant zero limbs are removed.
144157
FASTFLOAT_CONSTEXPR14 void normalize() noexcept {
145158
while (len() > 0 && rindex(0) == 0) {
@@ -423,6 +436,7 @@ struct bigint : pow5_tables<> {
423436
stackvec<bigint_limbs> vec;
424437

425438
FASTFLOAT_CONSTEXPR20 bigint() : vec() {}
439+
426440
bigint(bigint const &) = delete;
427441
bigint &operator=(bigint const &) = delete;
428442
bigint(bigint &&) = delete;

include/fast_float/digit_comparison.h

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ round_down(adjusted_mantissa &am, int32_t shift) noexcept {
170170
}
171171
am.power2 += shift;
172172
}
173+
173174
template <typename UC>
174175
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 void
175176
skip_zeros(UC const *&first, UC const *last) noexcept {
@@ -213,6 +214,7 @@ is_truncated(UC const *first, UC const *last) noexcept {
213214
}
214215
return false;
215216
}
217+
216218
template <typename UC>
217219
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 bool
218220
is_truncated(span<UC const> s) noexcept {

include/fast_float/fast_float.h

+1
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
5454
from_chars(UC const *first, UC const *last, T &value, int base = 10) noexcept;
5555

5656
} // namespace fast_float
57+
5758
#include "parse_number.h"
5859
#endif // FASTFLOAT_FAST_FLOAT_H

0 commit comments

Comments
 (0)