Skip to content

Commit 4dcd62b

Browse files
authored
Merge pull request #191 from Morwenn/develop
Release 1.11.0
2 parents 288efbc + ca9bfcb commit 4dcd62b

File tree

154 files changed

+2783
-1314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+2783
-1314
lines changed

.github/workflows/build-ubuntu.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ jobs:
4545
steps:
4646
- uses: actions/checkout@v2
4747

48+
- name: Install Clang
49+
if: ${{matrix.cxx == 'clang++-6.0'}}
50+
run: sudo apt-get install -y clang-6.0 lld-6.0
51+
4852
- name: Install Valgrind
4953
if: ${{matrix.config.valgrind == 'ON'}}
50-
run: sudo apt install -y valgrind
54+
run: sudo apt-get update && sudo apt-get install -y valgrind
5155

5256
- name: Configure CMake
5357
working-directory: ${{runner.workspace}}

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.8.0)
55

66
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
77

8-
project(cpp-sort VERSION 1.10.0 LANGUAGES CXX)
8+
project(cpp-sort VERSION 1.11.0 LANGUAGES CXX)
99

1010
include(CMakePackageConfigHelpers)
1111
include(GNUInstallDirs)

README.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
[![Latest Release](https://img.shields.io/badge/release-1.10.0-blue.svg)](https://github.com/Morwenn/cpp-sort/releases/tag/1.10.0)
2-
[![Conan Package](https://img.shields.io/badge/conan-cpp--sort%2F1.10.0-blue.svg)](https://conan.io/center/cpp-sort?version=1.10.0)
1+
[![Latest Release](https://img.shields.io/badge/release-1.11.0-blue.svg)](https://github.com/Morwenn/cpp-sort/releases/tag/1.11.0)
2+
[![Conan Package](https://img.shields.io/badge/conan-cpp--sort%2F1.11.0-blue.svg)](https://conan.io/center/cpp-sort?version=1.11.0)
33
[![Code Coverage](https://codecov.io/gh/Morwenn/cpp-sort/branch/develop/graph/badge.svg)](https://codecov.io/gh/Morwenn/cpp-sort)
44

55
> *It would be nice if only one or two of the sorting methods would dominate all of the others,
@@ -113,12 +113,10 @@ wiki page](https://github.com/Morwenn/cpp-sort/wiki/Benchmarks).
113113
![Windows builds status](https://github.com/Morwenn/cpp-sort/workflows/Windows%20Builds/badge.svg?branch=develop)
114114
![MacOS builds status](https://github.com/Morwenn/cpp-sort/workflows/MacOS%20Builds/badge.svg?branch=develop)
115115

116-
**cpp-sort** currently requires C++14 support, and only works with g++5 and clang++3.8
117-
or more recent versions of these compilers. So far, the library should work with the
118-
following compilers:
116+
**cpp-sort** requires C++14 support, and should work with the following compilers:
119117
* g++5.5 or more recent. It is known not to work with some older g++5 versions.
120-
* clang++6 or more recent. It should work with clang++ versions all the way back to 3.8, but the CI pipeline doesn't have test for those anymore.
121-
* Visual Studio 2019 version 16.8.3 or more recent, only with `/permissive-`. A few features are unavailable.
118+
* clang++6.0 or more recent. It should work with clang++ versions all the way back to 3.8, but the CI pipeline doesn't have test for those anymore.
119+
* Visual Studio 2019 version 16.8.3 or more recent, only with `/permissive-`. A few features are still unavailable.
122120
* The versions of MinGW-w64 and AppleClang equivalent to the compilers mentioned above.
123121
* Clang is notably tested with both libstdc++ and libc++.
124122

@@ -191,11 +189,11 @@ when there isn't enough memory available to perform an out-of-place merge.
191189
directly adapted from [Keith Schwarz's implementation](http://www.keithschwarz.com/interesting/code/?dir=smoothsort)
192190
of the algorithm.
193191

194-
* The algorithm used by `block_sorter` has been adapted from BonzaiThePenguin's
192+
* The algorithm used by `wiki_sorter` has been adapted from BonzaiThePenguin's
195193
[WikiSort](https://github.com/BonzaiThePenguin/WikiSort).
196194

197195
* The algorithm used by `grail_sorter` has been adapted from Mrrl's
198-
[GrailSort](https://github.com/Mrrl/GrailSort), hence the name.
196+
[GrailSort](https://github.com/Mrrl/GrailSort).
199197

200198
* The algorithm used by `indirect_adapter` with forward or bidirectional iterators is a
201199
slightly modified version of Matthew Bentley's [indiesort](https://github.com/mattreecebentley/plf_indiesort).

benchmarks/benchmarking-tools/distributions.h

+11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <cstddef>
77
#include <ctime>
88
#include <random>
9+
#include <string>
910
#include <utility>
1011
#include <vector>
1112
#include <cpp-sort/detail/bitops.h>
@@ -398,4 +399,14 @@ namespace dist
398399

399400
static constexpr const char* output = "vergesort_killer.txt";
400401
};
402+
403+
struct as_long_string
404+
{
405+
auto operator()(long long int value)
406+
-> std::string
407+
{
408+
auto str = std::to_string(value);
409+
return std::string(50 - str.size(), '0') + std::move(str);
410+
}
411+
};
401412
}

benchmarks/errorbar-plot/bench.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020 Morwenn
2+
* Copyright (c) 2020-2021 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#include <algorithm>
@@ -92,8 +92,7 @@ int main(int argc, char** argv)
9292

9393
auto total_start = clock_type::now();
9494
auto total_end = clock_type::now();
95-
while (std::chrono::duration_cast<std::chrono::seconds>(total_end - total_start) < max_run_time &&
96-
times.size() < max_runs_per_size) {
95+
while (total_end - total_start < max_run_time && times.size() < max_runs_per_size) {
9796
collection_t collection;
9897
distribution(std::back_inserter(collection), size);
9998
auto start = clock_type::now();

benchmarks/errorbar-plot/plot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# Copyright (c) 2020 Morwenn
3+
# Copyright (c) 2020-2021 Morwenn
44
# SPDX-License-Identifier: MIT
55

66
import argparse
@@ -58,7 +58,7 @@ def main():
5858

5959
ax.grid(True)
6060
ax.set_xlabel('Size')
61-
ax.set_ylabel('Time [s]')
61+
ax.set_ylabel('Time [s] (lower is better)')
6262
ax.set_xscale('log', base=2)
6363
ax.set_yscale('log')
6464

benchmarks/inversions/plot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# Copyright (c) 2020 Morwenn
3+
# Copyright (c) 2020-2021 Morwenn
44
# SPDX-License-Identifier: MIT
55

66
import argparse
@@ -59,5 +59,5 @@ def fetch_results(fresults):
5959
pyplot.legend(loc='best')
6060
pyplot.title('Sorting std::vector<int> with $10^6$ elements')
6161
pyplot.xlabel('Percentage of inversions')
62-
pyplot.ylabel('Cycles')
62+
pyplot.ylabel('Cycles (lower is better)')
6363
pyplot.show()

benchmarks/patterns/bars.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def main():
3636
parser.add_argument('--alternative-palette', dest='use_alt_palette',
3737
action='store_true', default=False,
3838
help="Use another color palette")
39+
parser.add_argument('--errorbars', dest='display_errorbars',
40+
action='store_true', default=False,
41+
help="Display errorbars")
3942
args = parser.parse_args()
4043

4144
distribution_names = {
@@ -73,8 +76,8 @@ def main():
7376
size = int(size)
7477
distribution = distribution_names[distribution]
7578
results = [int(result) for result in results]
76-
if not size in data: data[size] = {}
77-
if not distribution in data[size]: data[size][distribution] = {}
79+
data.setdefault(size, {})
80+
data[size].setdefault(distribution, {})
7881
data[size][distribution][algo] = results
7982

8083
# Choose the colour palette and markers to use
@@ -112,14 +115,15 @@ def main():
112115
for i, algo in enumerate(algos):
113116
heights = [numpy.median(data[size][distribution][algo]) for distribution in distributions]
114117
errors = [numpy.std(data[size][distribution][algo]) for distribution in distributions]
118+
kwargs = {"xerr": errors} if args.display_errorbars else {}
115119
pyplot.barh([barwidth * i + groupwidth * n for n in range(len(distributions))],
116-
heights, 0.6, color=next(colors), label=algo)
120+
heights, 0.6, color=next(colors), label=algo, **kwargs)
117121

118122
# Set axes limits and labels.
119123
groupnames = ['\n'.join(wrap(l, 11)) for l in groupnames]
120124
pyplot.yticks([barwidth * groupsize/2 + groupwidth*n for n in range(len(groupnames))],
121125
groupnames, horizontalalignment='center')
122-
pyplot.xlabel("Cycles per element")
126+
pyplot.xlabel("Cycles per element (lower is better)")
123127

124128
# Turn off ticks for y-axis.
125129
pyplot.tick_params(axis="y",

benchmarks/patterns/bench.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ int main()
8181
{ "verge_sort", cppsort::verge_sort },
8282
};
8383

84-
std::size_t sizes[] = { 10'000'000 };
84+
std::size_t sizes[] = { 1'000'000 };
8585

8686
// Poor seed, yet enough for our benchmarks
8787
std::uint_fast32_t seed = std::time(nullptr);
@@ -98,7 +98,7 @@ int main()
9898

9999
auto total_start = clock_type::now();
100100
auto total_end = clock_type::now();
101-
while (std::chrono::duration_cast<std::chrono::seconds>(total_end - total_start) < 5s) {
101+
while (total_end - total_start < 5s) {
102102
collection_t collection;
103103
distribution.second(std::back_inserter(collection), size);
104104
std::uint64_t start = rdtsc();
@@ -109,12 +109,15 @@ int main()
109109
total_end = clock_type::now();
110110
}
111111

112-
std::sort(std::begin(cycles), std::end(cycles));
113-
114-
std::cerr << size << ", " << distribution.first << ", " << sort.first
115-
<< ", " << cycles[cycles.size() / 2] << '\n';
116-
std::cout << size << ", " << distribution.first << ", " << sort.first
117-
<< ", " << cycles[cycles.size() / 2] << '\n';
112+
for (std::ostream* stream: {&std::cout, &std::cerr}) {
113+
(*stream) << size << ", " << distribution.first << ", " << sort.first << ", ";
114+
auto it = cycles.begin();
115+
(*stream) << *it;
116+
while (++it != cycles.end()) {
117+
(*stream) << ", " << *it;
118+
}
119+
(*stream) << std::endl;
120+
}
118121
}
119122
}
120123
}

benchmarks/small-array/plot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# Copyright (c) 2015-2020 Morwenn
3+
# Copyright (c) 2015-2021 Morwenn
44
# SPDX-License-Identifier: MIT
55

66
import sys
@@ -36,5 +36,5 @@ def fetch_results(fresults):
3636
plt.legend(values, names, loc='upper left')
3737
plt.title('Sorting std::array<int>')
3838
plt.xlabel('Number of elements to sort')
39-
plt.ylabel('Cycles')
39+
plt.ylabel('Cycles (lower is better)')
4040
plt.show()

conanfile.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
from conans import CMake, ConanFile
77

8+
required_conan_version = ">=1.33.0"
9+
810

911
class CppSortConan(ConanFile):
1012
name = "cpp-sort"
11-
version = "1.10.0"
13+
version = "1.11.0"
1214
description = "Additional sorting algorithms & related tools"
1315
topics = "conan", "cpp-sort", "sorting", "algorithms"
1416
url = "https://github.com/Morwenn/cpp-sort"
@@ -43,6 +45,8 @@ def package(self):
4345
self.copy(file, dst="licenses")
4446

4547
def package_info(self):
48+
self.cpp_info.names["cmake_find_package"] = "cpp-sort"
49+
self.cpp_info.names["cmake_find_package_multi"] = "cpp-sort"
4650
if self.settings.compiler == "Visual Studio":
4751
self.cpp_info.cxxflags = ["/permissive-"]
4852

0 commit comments

Comments
 (0)