mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-10 20:53:50 +01:00
Merge #13025: Dead code removal
1bf3f33b46node: Removed unused wallet-related methods from the Node interface. (Thomas Snider)b38200459fbenchmark: Removed bench/perf.cpp (Thomas Snider) Pull request description: Not sure if these should be separate PRs. First is removal of a platform abstraction for getting cycle counters where possible. Since the benchmarking switch to counting number of iterations over a fixed window instead of counting cycles per iteration, these are unused. Second is removal of a few methods from the Node interface that seem vestigial from when the concepts of wallet/node were not as clearly separated. Tree-SHA512: de1460a7d4473ca19db4e2ca845185c63c765d12462c2685044a1f27dedab266cd908bc52235a881a7ad98bc251a4abf4eae523e5f599c169e3511e489f19a0d
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <bench/bench.h>
|
||||
#include <bench/perf.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
@@ -96,7 +95,6 @@ benchmark::BenchRunner::BenchRunner(std::string name, benchmark::BenchFunction f
|
||||
|
||||
void benchmark::BenchRunner::RunAll(Printer& printer, uint64_t num_evals, double scaling, const std::string& filter, bool is_list_only)
|
||||
{
|
||||
perf_init();
|
||||
if (!std::ratio_less_equal<benchmark::clock::period, std::micro>::value) {
|
||||
std::cerr << "WARNING: Clock precision is worse than microsecond - benchmarks may be less accurate!\n";
|
||||
}
|
||||
@@ -126,8 +124,6 @@ void benchmark::BenchRunner::RunAll(Printer& printer, uint64_t num_evals, double
|
||||
}
|
||||
|
||||
printer.footer();
|
||||
|
||||
perf_fini();
|
||||
}
|
||||
|
||||
bool benchmark::State::UpdateTimer(const benchmark::time_point current_time)
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
// Copyright (c) 2016-2017 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <bench/perf.h>
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
/* These architectures support querying the cycle counter
|
||||
* from user space, no need for any syscall overhead.
|
||||
*/
|
||||
void perf_init(void) { }
|
||||
void perf_fini(void) { }
|
||||
|
||||
#elif defined(__linux__)
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <linux/perf_event.h>
|
||||
|
||||
static int fd = -1;
|
||||
static struct perf_event_attr attr;
|
||||
|
||||
void perf_init(void)
|
||||
{
|
||||
attr.type = PERF_TYPE_HARDWARE;
|
||||
attr.config = PERF_COUNT_HW_CPU_CYCLES;
|
||||
fd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0);
|
||||
}
|
||||
|
||||
void perf_fini(void)
|
||||
{
|
||||
if (fd != -1) {
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t perf_cpucycles(void)
|
||||
{
|
||||
uint64_t result = 0;
|
||||
if (fd == -1 || read(fd, &result, sizeof(result)) < (ssize_t)sizeof(result)) {
|
||||
return 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#else /* Unhandled platform */
|
||||
|
||||
void perf_init(void) { }
|
||||
void perf_fini(void) { }
|
||||
uint64_t perf_cpucycles(void) { return 0; }
|
||||
|
||||
#endif
|
||||
@@ -1,37 +0,0 @@
|
||||
// Copyright (c) 2016 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
/** Functions for measurement of CPU cycles */
|
||||
#ifndef BITCOIN_BENCH_PERF_H
|
||||
#define BITCOIN_BENCH_PERF_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__i386__)
|
||||
|
||||
static inline uint64_t perf_cpucycles(void)
|
||||
{
|
||||
uint64_t x;
|
||||
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
|
||||
return x;
|
||||
}
|
||||
|
||||
#elif defined(__x86_64__)
|
||||
|
||||
static inline uint64_t perf_cpucycles(void)
|
||||
{
|
||||
uint32_t hi, lo;
|
||||
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
|
||||
return ((uint64_t)lo)|(((uint64_t)hi)<<32);
|
||||
}
|
||||
#else
|
||||
|
||||
uint64_t perf_cpucycles(void);
|
||||
|
||||
#endif
|
||||
|
||||
void perf_init(void);
|
||||
void perf_fini(void);
|
||||
|
||||
#endif // BITCOIN_BENCH_PERF_H
|
||||
Reference in New Issue
Block a user