You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by rnewson <gi...@git.apache.org> on 2014/11/02 19:51:09 UTC

[GitHub] couchdb-couch-stats pull request: update_histogram with timing of ...

GitHub user rnewson opened a pull request:

    https://github.com/apache/couchdb-couch-stats/pull/3

    update_histogram with timing of a function

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/apache/couchdb-couch-stats histogram-fun

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-couch-stats/pull/3.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #3
    
----
commit 1bcffbdd260ac600336bb74db592b2481bb6a2e6
Author: Robert Newson <rn...@apache.org>
Date:   2014-11-01T16:32:16Z

    update_histogram with timing of a function

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-stats pull request: update_histogram with timing of ...

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch-stats/pull/3#discussion_r19714093
  
    --- Diff: src/couch_stats.erl ---
    @@ -87,8 +87,19 @@ decrement_counter(Name) ->
     decrement_counter(Name, Value) ->
         notify(Name, {dec, Value}).
     
    --spec update_histogram(any(), number()) -> response().
    -update_histogram(Name, Value) ->
    +-spec update_histogram(any(), number()) -> response();
    +                      (any(), function()) -> any().
    +update_histogram(Name, Fun) when is_function(Fun, 0) ->
    +    Begin = os:timestamp(),
    +    Result = Fun(),
    +    Duration = timer:now_diff(os:timestamp(), Begin) div 1000,
    --- End diff --
    
    Ah, it's a pity. Ok, good to know.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-stats pull request: update_histogram with timing of ...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/couchdb-couch-stats/pull/3


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-stats pull request: update_histogram with timing of ...

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the pull request:

    https://github.com/apache/couchdb-couch-stats/pull/3#issuecomment-61419060
  
    May be it also worth to add arguments support and module, but there is no such need for now. May be later.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-stats pull request: update_histogram with timing of ...

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch-stats/pull/3#discussion_r19714082
  
    --- Diff: src/couch_stats.erl ---
    @@ -87,8 +87,19 @@ decrement_counter(Name) ->
     decrement_counter(Name, Value) ->
         notify(Name, {dec, Value}).
     
    --spec update_histogram(any(), number()) -> response().
    -update_histogram(Name, Value) ->
    +-spec update_histogram(any(), number()) -> response();
    +                      (any(), function()) -> any().
    +update_histogram(Name, Fun) when is_function(Fun, 0) ->
    +    Begin = os:timestamp(),
    +    Result = Fun(),
    +    Duration = timer:now_diff(os:timestamp(), Begin) div 1000,
    --- End diff --
    
    except timer:tc/1 doesn't exist in R14, so we can't use it, unfortunately.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-stats pull request: update_histogram with timing of ...

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:

    https://github.com/apache/couchdb-couch-stats/pull/3#issuecomment-61423253
  
    merged.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-stats pull request: update_histogram with timing of ...

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the pull request:

    https://github.com/apache/couchdb-couch-stats/pull/3#issuecomment-61419025
  
    Looks good. I'll update my apache/couchdb-couch#13 when you merge it. Thanks! (:


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch-stats pull request: update_histogram with timing of ...

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch-stats/pull/3#discussion_r19714068
  
    --- Diff: src/couch_stats.erl ---
    @@ -87,8 +87,19 @@ decrement_counter(Name) ->
     decrement_counter(Name, Value) ->
         notify(Name, {dec, Value}).
     
    --spec update_histogram(any(), number()) -> response().
    -update_histogram(Name, Value) ->
    +-spec update_histogram(any(), number()) -> response();
    +                      (any(), function()) -> any().
    +update_histogram(Name, Fun) when is_function(Fun, 0) ->
    +    Begin = os:timestamp(),
    +    Result = Fun(),
    +    Duration = timer:now_diff(os:timestamp(), Begin) div 1000,
    --- End diff --
    
    That's actually what `timer:tc` does: https://github.com/erlang/otp/blob/maint/lib/stdlib/src/timer.erl#L192
    So may be:
    ```
    {Duration, Result} = timer:tc(Fun),
    case notify(Name, Duration div 1000) of
      ok ->
        Result;
      {error, unknown_metric} ->
        throw({unknown_metric, Name})
    end;
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---