Coder Social home page Coder Social logo

progress-cpp's Introduction

Hello ๐Ÿ‘‹

I'm Prakhar, a software engineer working on Firebase at Google! I live in San Francisco and love building awesome tools for developers. To know more about me visit my website.

Thanks for stopping by!

progress-cpp's People

Contributors

andersfylling avatar prakhar1989 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

progress-cpp's Issues

Using the library slows down my code execution extremely

Right now I'm working on a ray tracer and I thought it would be a nice touch to add in a progress bar on the command line. This looked simple enough so I grabbed. But after putting in, it's use drastically slowed down the render times. For example, I'm trying to render a 960x540 image (and about 10 samples per pixel).

  • If I don't use this library, on average it takes about 3.3 seconds on average to do a render.
  • If have the ticks set to the height of my render (e.g. ProgressBar(540, ...)) and incremented it after completing a row of pixels, it took on average it took 3.8 seconds to complete a render
  • If I have the ticks set to count all of the pixels of my render (e.g. ProgressBar(960 * 540, ...)) and increment after completing a single pixel, it took an average of 21 seconds (!!)

After taking a look in the display() code, I think the cause is all of the IO to standard output. There should be some better way to build the string that needs to be printed. I.e. buffer the output string. I can try to provide a solution to this if you'd like me to, but it might be a bit before I get around to it.

Not possible to nest multiple progressbars

Hey,
I tried nesting multiple progressbars like in this example:

#include <iostream>
#include "progressbar.hpp"

int main()
{
    ProgressBar pb1(100, 70);
    for (int i = 0; i < 100; ++i) {
        pb1.display();
        ++pb1;
        // Do additional stuff
        ProgressBar pb2(100, 70);
        for (int j = 0; j < 100; ++j) {
            pb2.display();
            ++pb2;
            // Do additional stuff
        }
        pb2.done();
    }
    pb1.done();
    return 0;
}

Unfortunately, this does not work. Instead the first progressbar disappears as soon as the second one gets displayed for the first time. After the second bar is finished, the first bar appears only for a brief moment, updates once, and disappears again.
Is there a way to nest two progressbars using the current implementation?
PS: If you want to run the example code, I recommend putting some sleep()/uslepp() in there, otherwise it will run too fast to notice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.