Giter Club home page Giter Club logo

codestopwatch's People

Contributors

mkhoudary avatar qamarelsafadi avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

codestopwatch's Issues

How about run task in multiple thread ?

How I can mark task that's work in multiple thread ?

     for (int i = 0; i < 10; i++) {

        CodeStopWatch.instance().start("Task Concurrency ");

        new Thread(() -> {
            CodeStopWatch.instance().mark("  mark 1 ");
            CodeStopWatch.instance().mark("  mark 2 ");
            CodeStopWatch.instance().mark("  mark 3 ");
        }).start();

        CodeStopWatch.instance().stop();
        CodeStopWatch.instance().print(false);

    }

the result is:

      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  started in 11/3/22, 10:21 AM
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  stopped in 11/3/22, 10:21 AM after 0.01s
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  started in 11/3/22, 10:21 AM
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  stopped in 11/3/22, 10:21 AM after 0.00s
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  started in 11/3/22, 10:21 AM
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  stopped in 11/3/22, 10:21 AM after 0.00s
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  started in 11/3/22, 10:21 AM
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  stopped in 11/3/22, 10:21 AM after 0.00s
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  started in 11/3/22, 10:21 AM
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  stopped in 11/3/22, 10:21 AM after 0.00s
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  started in 11/3/22, 10:21 AM
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  stopped in 11/3/22, 10:21 AM after 0.00s
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  started in 11/3/22, 10:21 AM
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  stopped in 11/3/22, 10:21 AM after 0.00s
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  started in 11/3/22, 10:21 AM
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  stopped in 11/3/22, 10:21 AM after 0.00s
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  started in 11/3/22, 10:21 AM
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  stopped in 11/3/22, 10:21 AM after 0.00s
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  started in 11/3/22, 10:21 AM
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: -----------------------------------------
      Nov 03, 2022 10:21:58 AM ps.purelogic.codestopwatch.CodeStopWatch print
      INFO: Stopwatch for Task Concurrency  stopped in 11/3/22, 10:21 AM after 0.01s

it will be work if you are using one instance for all operations ( mark, start, stop, print)

      CodeStopWatch codeStopWatch = CodeStopWatch.instance();

      for (int i = 0; i < 10; i++) {
          codeStopWatch.start("Task Concurrency ");

          new Thread(() -> {
              codeStopWatch.mark("  mark 1 ");
              codeStopWatch.mark("  mark 2 ");
              codeStopWatch.mark("  mark 3 ");
          }).start();

          codeStopWatch.stop();
          codeStopWatch.print(false);

      }

the result will be like this:

    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO: Stopwatch for Task Concurrency  started in 11/3/22, 10:26 AM
    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO: -----------------------------------------
    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO:   mark 1 	11/3/22, 10:26 AM	0.01s
    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO:   mark 2 	11/3/22, 10:26 AM	0.01s
    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO:   mark 3 	11/3/22, 10:26 AM	0.00s
    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO: -----------------------------------------
    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO: Stopwatch for Task Concurrency  stopped in 11/3/22, 10:26 AM after 0.01s
    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO: Stopwatch for Task Concurrency  started in 11/3/22, 10:26 AM
    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO: -----------------------------------------
    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO:   mark 1 	11/3/22, 10:26 AM	0.01s
    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO:   mark 2 	11/3/22, 10:26 AM	0.00s
    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO:   mark 3 	11/3/22, 10:26 AM	0.00s
    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO: -----------------------------------------
    Nov 03, 2022 10:26:03 AM ps.purelogic.codestopwatch.CodeStopWatch print
    INFO: Stopwatch for Task Concurrency  stopped in 11/3/22, 10:26 AM after 0.01s

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.