Skip to content

Commit

Permalink
Clang format (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
amallia committed Mar 6, 2020
1 parent f3afb5d commit 112f400
Show file tree
Hide file tree
Showing 57 changed files with 1,508 additions and 1,485 deletions.
117 changes: 73 additions & 44 deletions .clang-format
@@ -1,48 +1,77 @@
---
AccessModifierOffset: -1
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
AccessModifierOffset: '-2'
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: 'false'
AlignConsecutiveDeclarations: 'false'
AlignEscapedNewlines: Left
AlignOperands: 'false'
AlignTrailingComments: 'false'
AllowAllArgumentsOnNextLine: 'true'
AllowAllConstructorInitializersOnNextLine: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'true'
AlwaysBreakTemplateDeclarations: 'Yes'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: WebKit
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 100
CommentPragmas: '^@atd'
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
ExperimentalAutoDetectBinPacking: true
IndentCaseLabels: false
IndentFunctionDeclarationAfterType: false
IndentWidth: 4
MaxEmptyLinesToKeep: 1
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: 'true'
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BraceWrapping:
AfterFunction: true
SplitEmptyFunction: false
ColumnLimit: '100'
CompactNamespaces: 'true'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
ConstructorInitializerIndentWidth: '4'
ContinuationIndentWidth: '4'
Cpp11BracedListStyle: 'true'
DerivePointerAlignment: 'false'
DisableFormat: 'false'
ExperimentalAutoDetectBinPacking: 'false'
FixNamespaceComments: 'true'
IncludeBlocks: Preserve
IndentCaseLabels: 'false'
IndentPPDirectives: BeforeHash
IndentWidth: '4'
IndentWrappedFunctionNames: 'false'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
Language: Cpp
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: Inner
ObjCSpaceBeforeProtocolList: false
PenaltyBreakBeforeFirstCallParameter: 10
PenaltyBreakComment: 60
PenaltyBreakFirstLessLess: 20
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right
SpaceAfterControlStatementKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
PenaltyBreakAssignment: '1'
PenaltyBreakBeforeFirstCallParameter: '0'
PenaltyBreakComment: '0'
PenaltyBreakFirstLessLess: '1'
PenaltyBreakString: '2'
PenaltyExcessCharacter: '10'
PointerAlignment: Left
ReflowComments: 'true'
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterLogicalNot: 'false'
SpaceAfterTemplateKeyword: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'false'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'false'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'false'
SpaceInEmptyParentheses: 'false'
SpacesBeforeTrailingComments: '2'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: Cpp11
UseTab: Never
...
63 changes: 32 additions & 31 deletions benchmarks/index_perftest.cpp
@@ -1,13 +1,13 @@
#include "mappable/mapper.hpp"
#include "mio/mmap.hpp"
#include "spdlog/spdlog.h"
#include "mappable/mapper.hpp"

#include "index_types.hpp"
#include "util/util.hpp"
#include "util/do_not_optimize_away.hpp"
#include "util/util.hpp"

using pisa::get_time_usecs;
using pisa::do_not_optimize_away;
using pisa::get_time_usecs;

template <typename IndexType, bool with_freqs>
void perftest(IndexType const& index, std::string const& type)
Expand All @@ -18,10 +18,11 @@ void perftest(IndexType const& index, std::string const& type)
size_t max_length = 100000;
size_t max_number_of_lists = 1000;

spdlog::info("Scanning {} posting lists with length between {} and {}",
max_number_of_lists,
min_length,
max_length);
spdlog::info(
"Scanning {} posting lists with length between {} and {}",
max_number_of_lists,
min_length,
max_length);

std::vector<size_t> long_lists;
for (size_t i = 0; i < index.size() and long_lists.size() <= max_number_of_lists; ++i) {
Expand All @@ -47,11 +48,12 @@ void perftest(IndexType const& index, std::string const& type)
}
double elapsed = get_time_usecs() - tick;
double next_ns = elapsed / postings * 1000;
spdlog::info("Performed {} next(){} in {} seconds, {:.1f} ns per posting",
postings,
freqs_log,
uint64_t(elapsed / 1000000),
next_ns);
spdlog::info(
"Performed {} next(){} in {} seconds, {:.1f} ns per posting",
postings,
freqs_log,
uint64_t(elapsed / 1000000),
next_ns);
spdlog::info("{}\tnext{}\t{:.1f}", type, (with_freqs ? "_freq" : ""), next_ns);
}

Expand All @@ -63,11 +65,11 @@ void perftest(IndexType const& index, std::string const& type)
for (size_t i = 0; i < index.size(); ++i) {
auto reader = index[i];
uint64_t size = reader.size();
if (size < min_length) continue;
if (size < min_length)
continue;

skip_values.emplace_back(i, std::vector<uint64_t>());
for (size_t i = 0; i < std::min(pisa::ceil_div(size, skip),
max_calls_per_list); ++i) {
for (size_t i = 0; i < std::min(pisa::ceil_div(size, skip), max_calls_per_list); ++i) {
reader.move(i * skip);
skip_values.back().second.push_back(reader.docid());
}
Expand All @@ -89,11 +91,12 @@ void perftest(IndexType const& index, std::string const& type)
double elapsed = get_time_usecs() - tick;
double next_geq_ns = elapsed / calls * 1000;

spdlog::info("Performed {} calls next_geq(){} with skip={}: {:.1f} ns per call",
calls,
freqs_log,
skip,
next_geq_ns);
spdlog::info(
"Performed {} calls next_geq(){} with skip={}: {:.1f} ns per call",
calls,
freqs_log,
skip,
next_geq_ns);
spdlog::info(
"{}\tnext_geq{}\t{}\t{:.1f}", type, (with_freqs ? "_freq" : ""), skip, next_geq_ns);
}
Expand All @@ -111,27 +114,25 @@ void perftest(const char* index_filename, std::string const& type)
perftest<IndexType, true>(index, type);
}


int main(int argc, const char** argv) {

int main(int argc, const char** argv)
{
using namespace pisa;

if (argc != 3) {
std::cerr << "Usage: " << argv[0]
<< " <index type> <index filename>"
<< std::endl;
std::cerr << "Usage: " << argv[0] << " <index type> <index filename>" << std::endl;
return 1;
}

std::string type = argv[1];
const char* index_filename = argv[2];

if (false) {
#define LOOP_BODY(R, DATA, T) \
} else if (type == BOOST_PP_STRINGIZE(T)) { \
perftest<BOOST_PP_CAT(T, _index)> \
(index_filename, type); \
/**/
#define LOOP_BODY(R, DATA, T) \
} \
else if (type == BOOST_PP_STRINGIZE(T)) \
{ \
perftest<BOOST_PP_CAT(T, _index)>(index_filename, type); \
/**/

BOOST_PP_SEQ_FOR_EACH(LOOP_BODY, _, PISA_INDEX_TYPES);
#undef LOOP_BODY
Expand Down
5 changes: 2 additions & 3 deletions benchmarks/perftest_interpolative.cpp
@@ -1,12 +1,11 @@
#include <iostream>
#include <algorithm>
#include <iostream>

#include "spdlog/spdlog.h"

#include "util/util.hpp"
#include "codec/block_codecs.hpp"
#include "util/do_not_optimize_away.hpp"

#include "util/util.hpp"

int main()
{
Expand Down
53 changes: 28 additions & 25 deletions benchmarks/scan_perftest.cpp
Expand Up @@ -2,14 +2,14 @@
#include "spdlog/spdlog.h"

#include "mappable/mapper.hpp"
#include "sequence_collection.hpp"
#include "sequence/partitioned_sequence.hpp"
#include "sequence/uniform_partitioned_sequence.hpp"
#include "util/util.hpp"
#include "sequence_collection.hpp"
#include "util/do_not_optimize_away.hpp"
#include "util/util.hpp"

using pisa::get_time_usecs;
using pisa::do_not_optimize_away;
using pisa::get_time_usecs;

template <typename BaseSequence>
void perftest(const char* index_filename)
Expand All @@ -35,10 +35,11 @@ void perftest(const char* index_filename)
postings += calls;
}
double elapsed = get_time_usecs() - tick;
spdlog::info("Read {} postings in {} seconds, {:.1f} ns per posting",
postings,
uint64_t(elapsed / 1000000),
(elapsed / postings * 1000));
spdlog::info(
"Read {} postings in {} seconds, {:.1f} ns per posting",
postings,
uint64_t(elapsed / 1000000),
(elapsed / postings * 1000));
}

{
Expand All @@ -64,10 +65,11 @@ void perftest(const char* index_filename)
postings += calls;
}
double elapsed = get_time_usecs() - tick;
spdlog::info("Read {} postings in {} seconds, {:.1f} ns per posting",
postings,
uint64_t(elapsed / 1000000),
(elapsed / postings * 1000));
spdlog::info(
"Read {} postings in {} seconds, {:.1f} ns per posting",
postings,
uint64_t(elapsed / 1000000),
(elapsed / postings * 1000));
}

uint64_t calls_per_list = 20000;
Expand All @@ -80,7 +82,8 @@ void perftest(const char* index_filename)
if (reader.size() >= min_length) {
uint64_t size = reader.size();
// make sure size is odd, so that it is coprime with skip
if (!(size & 1)) size -= 1;
if (!(size & 1))
size -= 1;

skip_values.emplace_back(i, std::vector<uint64_t>());
skip_positions.emplace_back(i, std::vector<uint64_t>());
Expand All @@ -103,10 +106,11 @@ void perftest(const char* index_filename)
}
double elapsed = get_time_usecs() - tick;

spdlog::info("Performed {} next_geq() with skip={}: {:.1f} ns per call",
calls,
skip,
(elapsed / calls * 1000));
spdlog::info(
"Performed {} next_geq() with skip={}: {:.1f} ns per call",
calls,
skip,
(elapsed / calls * 1000));

tick = get_time_usecs();
calls = 0;
Expand All @@ -119,23 +123,22 @@ void perftest(const char* index_filename)
}
elapsed = get_time_usecs() - tick;

spdlog::info("Performed {} move() with skip={}: {:.1f} ns per call",
calls,
skip,
(elapsed / calls * 1000));
spdlog::info(
"Performed {} move() with skip={}: {:.1f} ns per call",
calls,
skip,
(elapsed / calls * 1000));
}
}
int main(int argc, const char** argv) {

int main(int argc, const char** argv)
{
using pisa::compact_elias_fano;
using pisa::indexed_sequence;
using pisa::partitioned_sequence;
using pisa::uniform_partitioned_sequence;

if (argc != 3) {
std::cerr << "Usage: " << argv[0]
<< " <collection type> <index filename>"
<< std::endl;
std::cerr << "Usage: " << argv[0] << " <collection type> <index filename>" << std::endl;
return 1;
}

Expand Down

0 comments on commit 112f400

Please sign in to comment.