Skip to content
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

Add documentation on Running Your First Benchmark #622

Closed
wants to merge 1 commit into from
Closed

Add documentation on Running Your First Benchmark #622

wants to merge 1 commit into from

Conversation

kanak
Copy link

@kanak kanak commented Jun 19, 2018

In #619 , the need for
documentation aimed at rank beginners was mentioned. Specifically, the
need for exact command line incantations and expected outputs.

This commit adds a new file inside docs that contains this
beginner-friendly documentation. The documentation was verified
against Fedora 28, but can be extended to add ubuntu and other os
information.

@kanak
Copy link
Author

kanak commented Jun 19, 2018

I'm new to the library and also not a native speaker, so I'm open to all feedback.

I'm also happy to add Ubuntu Linux instructions or additional instructions using Clang if necessary. I also did not remove or otherwise refactor any docs in the Readme, I can help with that work as well.

```

Notes:
* We use `-std=c++11` because benchmark library requires at least c++11. Replacing it with `c++14` or `c++17` also work.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't true, i think right now, c++11 is still not required for consumers

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

`make install` should result in lines that look like:

```
-- Install configuration: "RELEASE"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite messy.
I'm thinking that maybe you either want to specify a custom install prefix, or not install at all.
In either case, you'll need to specify the include/link paths.

Or maybe just use the packaged version?

Copy link
Author

@kanak kanak Jun 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, google benchmark is not available in the Fedora 28 repository right now, so I have to compile it from source.

I'll prepare instructions for the no install use case. The "install" related bits can then be an "appendix" in this document or just removed.

@coveralls
Copy link

coveralls commented Jun 19, 2018

Coverage Status

Coverage remained the same at 87.157% when pulling 6cc299a on kanak:run_first_benchmark_doc into 7d03f2d on google:master.

In #619 , the need for
documentation aimed at rank beginners was mentioned. Specifically, the
need for exact command line incantations and expected outputs.

This commit adds a new file inside docs that contains this
beginner-friendly documentation. The documentation was verified
against Fedora 28, but can be extended to add ubuntu and other os
information.
@AppVeyorBot
Copy link

Build benchmark 1297 completed (commit 6c0ae4037f by @)


This tutorial is aimed at people new to the library and shows you how to run benchmarks with the Google Benchmark library.

# Install the prerequisites
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only be necessary if a package is not available. Ie, it might be worth having a section on getting the library first, with installation from source being one of the options.

* cmake : to build google benchmark
* make : to build google benchmark. Advanced users can use an alternative cmake backend like ninja.
* g++ : to compile your c++ code. Advanced users can use other compilers like clang instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmake or bazel (bazel is preferred)
make or ninja or visual studio for windows
g++ or clang++ can be replaced by "A C++ compiler with C++11 support"

* g++ : 8.1.1 20180502
* cmake : 3.11.2
* gnu make: 4.2.1
* git: 2.17.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to avoid this specificity and just have the users install the packages however they know how. there are too many platforms and variants to go into detail.


# Build and install Google Benchmark

Follow the instructions elsewhere to build and install the google-benchmark library.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a doc on building and (optionally) installing and link to it, then remove the same instructions from the base README file.

-- Installing: /usr/local/lib/cmake/benchmark/benchmarkTargets-release.cmake
```

Note the locations of the header file (`benchmark.h`) and the static library (`libbenchmark.a`); you might have to tell your compiler to look for libraries in those paths. Things worked out of the box in Fedora 28.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be necessary unless the user overrides the install location, in which case they know what they're doing. :)


# Build your first benchmark

Save this file as `BenchmarkMain.cpp`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe leave out the specifics of naming if you can. there are many standards around and this is irrelevant for library usage.


```
g++ BenchMain.cpp -std=c++11 -lbenchmark -lpthread -O2 -o BenchMain
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, we work against many platforms. I think it's better to have more generic instructions about building your executable and linking against the library, then have a section below on requirements like pthread and benchmark. Users on different platforms will have different ways of linking against those libraries.

@dmah42
Copy link
Member

dmah42 commented Mar 18, 2019

is this still something you wanted to pursue?

@kanak
Copy link
Author

kanak commented Mar 18, 2019

@dominichamon : I would like to abandon this effort. I understand the concerns laid out here, that this documentation would be too specific and overly prescriptive and unsuitable in its form as a piece of official documentation. However, I wrote this when I was running into some really basic problems (in retrospect), such as passing the -lbenchmark flag in the wrong place, and want a very rigid set of steps that was guaranteed to work. I think I will probably just publish this as a blog post instead.

Thank you for your time and for the wonderful library.

@dmah42
Copy link
Member

dmah42 commented Aug 18, 2020

thanks, @kanak

@dmah42 dmah42 closed this Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants