Skip to content

Commit

Permalink
Merge pull request #191 from Morwenn/develop
Browse files Browse the repository at this point in the history
Release 1.11.0
  • Loading branch information
Morwenn committed Jul 24, 2021
2 parents 288efbc + ca9bfcb commit 4dcd62b
Show file tree
Hide file tree
Showing 154 changed files with 2,783 additions and 1,314 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build-ubuntu.yml
Expand Up @@ -45,9 +45,13 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Install Clang
if: ${{matrix.cxx == 'clang++-6.0'}}
run: sudo apt-get install -y clang-6.0 lld-6.0

- name: Install Valgrind
if: ${{matrix.config.valgrind == 'ON'}}
run: sudo apt install -y valgrind
run: sudo apt-get update && sudo apt-get install -y valgrind

- name: Configure CMake
working-directory: ${{runner.workspace}}
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.8.0)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

project(cpp-sort VERSION 1.10.0 LANGUAGES CXX)
project(cpp-sort VERSION 1.11.0 LANGUAGES CXX)

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
Expand Down
16 changes: 7 additions & 9 deletions README.md
@@ -1,5 +1,5 @@
[![Latest Release](https://img.shields.io/badge/release-1.10.0-blue.svg)](https://github.com/Morwenn/cpp-sort/releases/tag/1.10.0)
[![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)
[![Latest Release](https://img.shields.io/badge/release-1.11.0-blue.svg)](https://github.com/Morwenn/cpp-sort/releases/tag/1.11.0)
[![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)
[![Code Coverage](https://codecov.io/gh/Morwenn/cpp-sort/branch/develop/graph/badge.svg)](https://codecov.io/gh/Morwenn/cpp-sort)

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

**cpp-sort** currently requires C++14 support, and only works with g++5 and clang++3.8
or more recent versions of these compilers. So far, the library should work with the
following compilers:
**cpp-sort** requires C++14 support, and should work with the following compilers:
* g++5.5 or more recent. It is known not to work with some older g++5 versions.
* 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.
* Visual Studio 2019 version 16.8.3 or more recent, only with `/permissive-`. A few features are unavailable.
* 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.
* Visual Studio 2019 version 16.8.3 or more recent, only with `/permissive-`. A few features are still unavailable.
* The versions of MinGW-w64 and AppleClang equivalent to the compilers mentioned above.
* Clang is notably tested with both libstdc++ and libc++.

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

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

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

* The algorithm used by `indirect_adapter` with forward or bidirectional iterators is a
slightly modified version of Matthew Bentley's [indiesort](https://github.com/mattreecebentley/plf_indiesort).
Expand Down
11 changes: 11 additions & 0 deletions benchmarks/benchmarking-tools/distributions.h
Expand Up @@ -6,6 +6,7 @@
#include <cstddef>
#include <ctime>
#include <random>
#include <string>
#include <utility>
#include <vector>
#include <cpp-sort/detail/bitops.h>
Expand Down Expand Up @@ -398,4 +399,14 @@ namespace dist

static constexpr const char* output = "vergesort_killer.txt";
};

struct as_long_string
{
auto operator()(long long int value)
-> std::string
{
auto str = std::to_string(value);
return std::string(50 - str.size(), '0') + std::move(str);
}
};
}
5 changes: 2 additions & 3 deletions benchmarks/errorbar-plot/bench.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 Morwenn
* Copyright (c) 2020-2021 Morwenn
* SPDX-License-Identifier: MIT
*/
#include <algorithm>
Expand Down Expand Up @@ -92,8 +92,7 @@ int main(int argc, char** argv)

auto total_start = clock_type::now();
auto total_end = clock_type::now();
while (std::chrono::duration_cast<std::chrono::seconds>(total_end - total_start) < max_run_time &&
times.size() < max_runs_per_size) {
while (total_end - total_start < max_run_time && times.size() < max_runs_per_size) {
collection_t collection;
distribution(std::back_inserter(collection), size);
auto start = clock_type::now();
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/errorbar-plot/plot.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Copyright (c) 2020 Morwenn
# Copyright (c) 2020-2021 Morwenn
# SPDX-License-Identifier: MIT

import argparse
Expand Down Expand Up @@ -58,7 +58,7 @@ def main():

ax.grid(True)
ax.set_xlabel('Size')
ax.set_ylabel('Time [s]')
ax.set_ylabel('Time [s] (lower is better)')
ax.set_xscale('log', base=2)
ax.set_yscale('log')

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/inversions/plot.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Copyright (c) 2020 Morwenn
# Copyright (c) 2020-2021 Morwenn
# SPDX-License-Identifier: MIT

import argparse
Expand Down Expand Up @@ -59,5 +59,5 @@ def fetch_results(fresults):
pyplot.legend(loc='best')
pyplot.title('Sorting std::vector<int> with $10^6$ elements')
pyplot.xlabel('Percentage of inversions')
pyplot.ylabel('Cycles')
pyplot.ylabel('Cycles (lower is better)')
pyplot.show()
12 changes: 8 additions & 4 deletions benchmarks/patterns/bars.py
Expand Up @@ -36,6 +36,9 @@ def main():
parser.add_argument('--alternative-palette', dest='use_alt_palette',
action='store_true', default=False,
help="Use another color palette")
parser.add_argument('--errorbars', dest='display_errorbars',
action='store_true', default=False,
help="Display errorbars")
args = parser.parse_args()

distribution_names = {
Expand Down Expand Up @@ -73,8 +76,8 @@ def main():
size = int(size)
distribution = distribution_names[distribution]
results = [int(result) for result in results]
if not size in data: data[size] = {}
if not distribution in data[size]: data[size][distribution] = {}
data.setdefault(size, {})
data[size].setdefault(distribution, {})
data[size][distribution][algo] = results

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

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

# Turn off ticks for y-axis.
pyplot.tick_params(axis="y",
Expand Down
19 changes: 11 additions & 8 deletions benchmarks/patterns/bench.cpp
Expand Up @@ -81,7 +81,7 @@ int main()
{ "verge_sort", cppsort::verge_sort },
};

std::size_t sizes[] = { 10'000'000 };
std::size_t sizes[] = { 1'000'000 };

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

auto total_start = clock_type::now();
auto total_end = clock_type::now();
while (std::chrono::duration_cast<std::chrono::seconds>(total_end - total_start) < 5s) {
while (total_end - total_start < 5s) {
collection_t collection;
distribution.second(std::back_inserter(collection), size);
std::uint64_t start = rdtsc();
Expand All @@ -109,12 +109,15 @@ int main()
total_end = clock_type::now();
}

std::sort(std::begin(cycles), std::end(cycles));

std::cerr << size << ", " << distribution.first << ", " << sort.first
<< ", " << cycles[cycles.size() / 2] << '\n';
std::cout << size << ", " << distribution.first << ", " << sort.first
<< ", " << cycles[cycles.size() / 2] << '\n';
for (std::ostream* stream: {&std::cout, &std::cerr}) {
(*stream) << size << ", " << distribution.first << ", " << sort.first << ", ";
auto it = cycles.begin();
(*stream) << *it;
while (++it != cycles.end()) {
(*stream) << ", " << *it;
}
(*stream) << std::endl;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/small-array/plot.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

# Copyright (c) 2015-2020 Morwenn
# Copyright (c) 2015-2021 Morwenn
# SPDX-License-Identifier: MIT

import sys
Expand Down Expand Up @@ -36,5 +36,5 @@ def fetch_results(fresults):
plt.legend(values, names, loc='upper left')
plt.title('Sorting std::array<int>')
plt.xlabel('Number of elements to sort')
plt.ylabel('Cycles')
plt.ylabel('Cycles (lower is better)')
plt.show()
6 changes: 5 additions & 1 deletion conanfile.py
Expand Up @@ -5,10 +5,12 @@

from conans import CMake, ConanFile

required_conan_version = ">=1.33.0"


class CppSortConan(ConanFile):
name = "cpp-sort"
version = "1.10.0"
version = "1.11.0"
description = "Additional sorting algorithms & related tools"
topics = "conan", "cpp-sort", "sorting", "algorithms"
url = "https://github.com/Morwenn/cpp-sort"
Expand Down Expand Up @@ -43,6 +45,8 @@ def package(self):
self.copy(file, dst="licenses")

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "cpp-sort"
self.cpp_info.names["cmake_find_package_multi"] = "cpp-sort"
if self.settings.compiler == "Visual Studio":
self.cpp_info.cxxflags = ["/permissive-"]

Expand Down

0 comments on commit 4dcd62b

Please sign in to comment.