Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Reimplementation of qsort function from glibc with more ability to inline comparison function.

License

NotificationsYou must be signed in to change notification settings

DieTime/qqsort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: BSD 3-ClauseUsage Single Header

Theqqsort macro is a reimplementation ofqsort function from glibc with more ability to inline comparison function.

Usage

#include<stdio.h>#include"qqsort.h"intmain(void) {intarray[]= {4,3,2,1,0,5,6,7,8,9};intsize=sizeof(array) /sizeof(array[0]);qqsort(array,size,sizeof(int),qqsortcmp(int*a,int*b) {qqsortret(*a-*b);           });for (intidx=0;idx<size;idx++) {printf("%d ",array[idx]);    }return0;}

Benchmark

❗This project is just an experiment to study the influence of inlining on code performance.

Machine used for benchmark:

  • AMD Ryzen 7 5800x
  • 16GB RAM
  • Linux 6.2.0

For the benchmark, a simple C++program was implemented to sort an array of structures in three ways:

  • Sorting usingstl
  • Sorting using theqsort function of the library
  • Sorting with theqqsort macro

Three compilers were used to build the benchmark:

  • g++ 11.4.0
  • clang++ 14.0.0
  • msvc 19.37

The following compilation flags were used:

COMPILE_ARGS= ["-flto","-O2", ... ]

Theqqsort macro showed positive results in performance only when using theg++ andmsvc compilers. When usingclang++, theqqsort macro performs worse than theqsort function.

benchmark-g++benchmark-msvcbenchmark-clang++

About

Reimplementation of qsort function from glibc with more ability to inline comparison function.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp