8000 Add benchmarks for blame by ethomson · Pull Request #6920 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

Add benchmarks for blame #6920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ name: Benchmark

on:
workflow_dispatch:
inputs:
suite:
description: Benchmark suite to run
debug:
type: boolean
description: Debugging output
schedule:
- cron: '15 4 * * *'

Expand Down Expand Up @@ -62,21 +68,42 @@ jobs:
run: source/ci/setup-${{ matrix.platform.setup-script }}-benchmark.sh
shell: bash
if: matrix.platform.setup-script != ''
- name: Clone resource repositories
run: |
mkdir resources
git clone --bare https://github.com/git/git resources/git
git clone --bare https://github.com/torvalds/linux resources/linux
- name: Build
run: |
mkdir build && cd build
../source/ci/build.sh
shell: bash
- name: Benchmark
run: |
export BENCHMARK_GIT_REPOSITORY="$(pwd)/resources/git"
# avoid linux temporarily; the linux blame benchmarks are simply
# too slow to use
# export BENCHMARK_LINUX_REPOSITORY="$(pwd)/resources/linux"

if [[ "$(uname -s)" == MINGW* ]]; then
GIT2_CLI="$(cygpath -w $(pwd))\\build\\Release\\git2"
else
GIT2_CLI="$(pwd)/build/git2"
fi

if [ "${{ github.event.inputs.suite }}" != "" ]; then
SUITE_FLAG="--suite ${{ github.event.inputs.suite }}"
fi

if [ "${{ github.event.inputs.debug }}" = "true" ]; then
DEBUG_FLAG="--debug"
fi

mkdir benchmark && cd benchmark
../source/tests/benchmarks/benchmark.sh --baseline-cli "git" --cli "${GIT2_CLI}" --name libgit2 --json benchmarks.json --zip benchmarks.zip
../source/tests/benchmarks/benchmark.sh \
${SUITE_FLAG} ${DEBUG_FLAG} \
--baseline-cli "git" --cli "${GIT2_CLI}" --name libgit2 \
--json benchmarks.json --zip benchmarks.zip
shell: bash
- name: Upload results
uses: actions/upload-artifact@v4
Expand All @@ -89,7 +116,7 @@ jobs:
publish:
name: Publish results
needs: [ build ]
if: always() && github.repository == 'libgit2/libgit2'
if: always() && github.repository == 'libgit2/libgit2' && github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Check out benchmark repository
Expand Down
5 changes: 2 additions & 3 deletions src/cli/cmd_blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

static char *file;
static int porcelain, line_porcelain;
static int show_help;

static const cli_opt_spec opts[] = {
CLI_COMMON_OPT,
Expand All @@ -40,7 +39,7 @@ static const cli_opt_spec opts[] = {

static void print_help(void)
{
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts);
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts, 0);
printf("\n");

printf("Show the origin of each line of a file.\n");
Expand Down Expand Up @@ -254,7 +253,7 @@ int cmd_blame(int argc, char **argv)
if (cli_opt_parse(&invalid_opt, opts, argv + 1, argc - 1, CLI_OPT_PARSE_GNU))
return cli_opt_usage_error(COMMAND_NAME, opts, &invalid_opt);

if (show_help) {
if (cli_opt__show_help) {
print_help();
return 0;
}
Expand Down
5 changes: 2 additions & 3 deletions src/cli/cmd_cat_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ typedef enum {
DISPLAY_TYPE
} display_t;

static int show_help;
static int display = DISPLAY_CONTENT;
static char *type_name, *object_spec;

Expand All @@ -43,7 +42,7 @@ static const cli_opt_spec opts[] = {

static void print_help(void)
{
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts);
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts, 0);
printf("\n");

printf("Display the content for the given object in the repository.\n");
Expand Down Expand Up @@ -147,7 +146,7 @@ int cmd_cat_file(int argc, char **argv)
if (cli_opt_parse(&invalid_opt, opts, argv + 1, argc - 1, CLI_OPT_PARSE_GNU))
return cli_opt_usage_error(COMMAND_NAME, opts, &invalid_opt);

if (show_help) {
if (cli_opt__show_help) {
print_help();
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/cli/cmd_clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define COMMAND_NAME "clone"

static char *branch, *remote_path, *local_path, *depth;
static int show_help, quiet, checkout = 1, bare;
static int quiet, checkout = 1, bare;
static bool local_path_exists;
static cli_progress progress = CLI_PROGRESS_INIT;

Expand All @@ -46,7 +46,7 @@ static const cli_opt_spec opts[] = {

static void print_help(void)
{
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts);
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts, 0);
printf("\n");

printf("Clone a repository into a new directory.\n");
Expand Down Expand Up @@ -133,7 +133,7 @@ int cmd_clone(int argc, char **argv)
if (cli_opt_parse(&invalid_opt, opts, argv + 1, argc - 1, CLI_OPT_PARSE_GNU))
return cli_opt_usage_error(COMMAND_NAME, opts, &invalid_opt);

if (show_help) {
if (cli_opt__show_help) {
print_help();
return 0;
}
Expand Down
5 changes: 2 additions & 3 deletions src/cli/cmd_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ typedef enum {
static action_t action = ACTION_NONE;
static int show_origin;
static int show_scope;
static int show_help;
static int null_separator;
static int config_level;
static char *config_filename;
Expand Down Expand Up @@ -68,7 +67,7 @@ static const cli_opt_spec opts[] = {

static void print_help(void)
{
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts);
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts, 0);
printf("\n");

printf("Query and set configuration options.\n");
Expand Down Expand Up @@ -180,7 +179,7 @@ int cmd_config(int argc, char **argv)
if (cli_opt_parse(&invalid_opt, opts, argv + 1, argc - 1, CLI_OPT_PARSE_GNU))
return cli_opt_usage_error(COMMAND_NAME, opts, &invalid_opt);

if (show_help) {
if (cli_opt__show_help) {
print_help();
return 0;
}
Expand Down
5 changes: 2 additions & 3 deletions src/cli/cmd_hash_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#define COMMAND_NAME "hash-object"

static int show_help;
static char *type_name;
static int write_object, read_stdin, literally;
static char **filenames;
Expand All @@ -36,7 +35,7 @@ static const cli_opt_spec opts[] = {

static void print_help(void)
{
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts);
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts, 0);
printf("\n");

printf("Compute the object ID for a given file and optionally write that file\nto the object database.\n");
Expand Down Expand Up @@ -103,7 +102,7 @@ int cmd_hash_object(int argc, char **argv)
if (cli_opt_parse(&invalid_opt, opts, argv + 1, argc - 1, CLI_OPT_PARSE_GNU))
return cli_opt_usage_error(COMMAND_NAME, opts, &invalid_opt);

if (show_help) {
if (cli_opt__show_help) {
print_help();
return 0;
}
Expand Down
7 changes: 3 additions & 4 deletions src/cli/cmd_help.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define COMMAND_NAME "help"

static char *command;
static int show_help;

static const cli_opt_spec opts[] = {
CLI_COMMON_OPT,
Expand All @@ -25,7 +24,7 @@ static const cli_opt_spec opts[] = {

static int print_help(void)
{
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts);
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts, CLI_OPT_USAGE_SHOW_HIDDEN);
printf("\n");

printf("Display help information about %s. If a command is specified, help\n", PROGRAM_NAME);
Expand All @@ -39,7 +38,7 @@ static int print_commands(void)
{
const cli_cmd_spec *cmd;

cli_opt_usage_fprint(stdout, PROGRAM_NAME, NULL, cli_common_opts);
cli_opt_usage_fprint(stdout, PROGRAM_NAME, NULL, cli_common_opts, CLI_OPT_USAGE_SHOW_HIDDEN);
printf("\n");

printf("These are the %s commands available:\n\n", PROGRAM_NAME);
Expand All @@ -62,7 +61,7 @@ int cmd_help(int argc, char **argv)
return cli_opt_usage_error(COMMAND_NAME, opts, &invalid_opt);

/* Show the meta-help */
if (show_help)
if (cli_opt__show_help)
return print_help();

/* We were not asked to show help for a specific command. */
Expand Down
10 changes: 4 additions & 6 deletions src/cli/cmd_index_pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@

#define BUFFER_SIZE (1024 * 1024)

static int show_help, verbose, read_stdin;
static int verbose, read_stdin;
static char *filename;
static cli_progress progress = CLI_PROGRESS_INIT;

static const cli_opt_spec opts[] = {
{ CLI_OPT_TYPE_SWITCH, "help", 0, &show_help, 1,
CLI_OPT_USAGE_HIDDEN | CLI_OPT_USAGE_STOP_PARSING, NULL,
"display help about the " COMMAND_NAME " command" },
CLI_COMMON_OPT,

{ CLI_OPT_TYPE_SWITCH, "verbose", 'v', &verbose, 1,
CLI_OPT_USAGE_DEFAULT, NULL, "display progress output" },
Expand All @@ -38,7 +36,7 @@ static const cli_opt_spec opts[] = {

static void print_help(void)
{
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts);
cli_opt_usage_fprint(stdout, PROGRAM_NAME, COMMAND_NAME, opts, 0);
printf("\n");

printf("Indexes a packfile and writes the index to disk.\n");
Expand All @@ -62,7 +60,7 @@ int cmd_index_pack(int argc, char **argv)
if (cli_opt_parse(&invalid_opt, opts, argv + 1, argc - 1, CLI_OPT_PARSE_GNU))
return cli_opt_usage_error(COMMAND_NAME, opts, &invalid_opt);

if (show_help) {
if (cli_opt__show_help) {
print_help();
return 0;
}
Expand Down
44 changes: 18 additions & 26 deletions src/cli/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,31 @@
* Common command arguments.
*/

extern int cli_opt__show_help;
extern int cli_opt__use_pager;

#define CLI_COMMON_OPT_HELP \
CLI_OPT_TYPE_SWITCH, "help", 0, &show_help, 1, \
CLI_OPT_USAGE_HIDDEN | CLI_OPT_USAGE_STOP_PARSING
CLI_OPT_TYPE_SWITCH, "help", 0, &cli_opt__show_help, 1, \
CLI_OPT_USAGE_HIDDEN | CLI_OPT_USAGE_STOP_PARSING, \
NULL, "display help information"
#define CLI_COMMON_OPT_CONFIG \
CLI_OPT_TYPE_VALUE, NULL, 'c', NULL, 0, \
CLI_OPT_USAGE_HIDDEN
CLI_OPT_TYPE_VALUE, NULL, 'c', NULL, 0, \
CLI_OPT_USAGE_HIDDEN, \
"key=value", "add configuration value"
#define CLI_COMMON_OPT_CONFIG_ENV \
CLI_OPT_TYPE_VALUE, "config-env", 0, NULL, 0, \
CLI_OPT_USAGE_HIDDEN
CLI_OPT_TYPE_VALUE, "config-env", 0, NULL, 0, \
CLI_OPT_USAGE_HIDDEN, \
"key=value", "set configuration value to environment variable"
#define CLI_COMMON_OPT_NO_PAGER \
CLI_OPT_TYPE_SWITCH, "no-pager", 0, &cli_opt__use_pager, 0, \
CLI_OPT_USAGE_HIDDEN, \
NULL, "don't paginate multi-page output"

#define CLI_COMMON_OPT \
{ CLI_COMMON_OPT_HELP }, \
{ CLI_COMMON_OPT_CONFIG }, \
{ CLI_COMMON_OPT_CONFIG_ENV }
{ CLI_COMMON_OPT_CONFIG_ENV }, \
{ CLI_COMMON_OPT_NO_PAGER }

typedef struct {
char **args;
Expand All @@ -49,23 +60,4 @@ extern int cli_resolve_path(
git_repository *repo,
const char *given_path);

/*
* Common command arguments.
*/

#define CLI_COMMON_OPT_HELP \
CLI_OPT_TYPE_SWITCH, "help", 0, &show_help, 1, \
CLI_OPT_USAGE_HIDDEN | CLI_OPT_USAGE_STOP_PARSING
#define CLI_COMMON_OPT_CONFIG \
CLI_OPT_TYPE_VALUE, NULL, 'c', NULL, 0, \
CLI_OPT_USAGE_HIDDEN
#define CLI_COMMON_OPT_CONFIG_ENV \
CLI_OPT_TYPE_VALUE, "config-env", 0, NULL, 0, \
CLI_OPT_USAGE_HIDDEN

#define CLI_COMMON_OPT \
{ CLI_COMMON_OPT_HELP }, \
{ CLI_COMMON_OPT_CONFIG }, \
{ CLI_COMMON_OPT_CONFIG_ENV }

#endif /* CLI_common_h__ */
28 changes: 20 additions & 8 deletions src/cli/main.c
EAD0
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@
#include "common.h"
#include "cmd.h"

static int show_help = 0;
int cli_opt__show_help = 0;
int cli_opt__use_pager = 1;

static int show_version = 0;
static char *command = NULL;
static char **args = NULL;

const cli_opt_spec cli_common_opts[] = {
{ CLI_OPT_TYPE_SWITCH, "help", 0, &show_help, 1,
CLI_OPT_USAGE_DEFAULT, NULL, "display help information" },
{ CLI_OPT_TYPE_VALUE, NULL, 'c', NULL, 0,
CLI_OPT_USAGE_DEFAULT, "key=value", "add configuration value" },
{ CLI_OPT_TYPE_VALUE, "config-env", 0, NULL, 0,
CLI_OPT_USAGE_DEFAULT, "key=value", "set configuration value to environment variable" },
CLI_COMMON_OPT,

{ CLI_OPT_TYPE_SWITCH, "version", 0, &show_version, 1,
CLI_OPT_USAGE_DEFAULT, NULL, "display the version" },
{ CLI_OPT_TYPE_ARG, "command", 0, &command, 0,
Expand Down Expand Up @@ -64,6 +62,19 @@ static void reorder_args(char **argv, size_t first)
argv[1] = tmp;
}

/*
* When invoked without a command, or just with `--help`, we invoke
* the help command; but we want to preserve only arguments that would
* be useful for that.
*/
static void help_args(int *argc, char **argv)
{
cli_opt__show_help = 0;

argv[0] = "help";
*argc = 1;
}

int main(int argc, char **argv)
{
const cli_cmd_spec *cmd;
Expand All @@ -82,7 +93,7 @@ int main(int argc, char **argv)
while (cli_opt_parser_next(&opt, &optparser)) {
if (!opt.spec) {
cli_opt_status_fprint(stderr, PROGRAM_NAME, &opt);
cli_opt_usage_fprint(stderr, PROGRAM_NAME, NULL, cli_common_opts);
cli_opt_usage_fprint(stderr, PROGRAM_NAME, NULL, cli_common_opts, CLI_OPT_USAGE_SHOW_HIDDEN);
ret = CLI_EXIT_USAGE;
goto done;
}
Expand All @@ -103,6 +114,7 @@ int main(int argc, char **argv)
}

if (!command) {
help_args(&argc, argv);
ret = cmd_help(argc, argv);
goto done;
}
Expand Down
Loading
Loading
0