xaizek / hstr (License: Apachev2) (since 2018-12-07)
Bash and Zsh shell history suggest box - easily view, navigate, search and manage your command history.
<root> / tests / src / test_ranking.c (ab1bca7aa128f9a1dca688c47d1071f69b0b71a7) (1,998B) (mode 100644) [raw]
/*
 ============================================================================
 Name        : test_ranking.c
 Author      : martin.dvorak@mindforger.com
 Copyright   : Apache 2.0
 Description : A test
 ============================================================================
*/

#include <stdio.h>
#include <math.h>

void testLog() {
    const int HISTORY_SIZE=2000;
    int i;
    for(i=0; i<HISTORY_SIZE; i++) {
        printf("\n%d # l: %f # l10: %f # l2: %f", i, log(i), log10(i), log2(i));
    }
}

#define MAX_CHARACTER_CODE 10000
static char line[MAX_CHARACTER_CODE];

void testGenerateHugeHistoryFileWithDifferentLines()
{
    FILE *file = fopen(".bash_history_huge","a");
    fseek(file,0, SEEK_END);

    line[0]=0;
    int i;
    for(i=0; i<MAX_CHARACTER_CODE; i++) {
        sprintf(line,"%s%c",line,i);
        fprintf(file,"%s\n",line);
    }
    fclose(file);
}


void testGenerateHugeHistoryFileWithSameLines()
{
    FILE *file = fopen(".bash_history_same","a");
    fseek(file,0, SEEK_END);

    int i;
    for(i=0; i<100000; i++) {
        fprintf(file,"find . | while read X; do echo $X; cat $X | grep -i ctrl; done | less\n",line);
        fprintf(file,
                "git commit -a -m \"Code review and stabilization.\" && git push origin master#"
                "git commit -a -m \"Code review and stabilization.\" && git push origin master#"
                "git commit -a -m \"Code review and stabilization.\" && git push origin master#"
                "git commit -a -m \"Code review and stabilization.\" && git push origin master#"
                "git commit -a -m \"Code review and stabilization.\" && git push origin master#"
                "git commit -a -m \"Code review and stabilization.\" && git push origin master#"
                "git commit -a -m \"Code review and stabilization.\" && git push origin master\n",
                line);
    }
    fclose(file);
}


int main(int argc, char *argv[])
{
    testGenerateHugeHistoryFileWithSameLines();
}

Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/hstr

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/hstr

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master