Github user rnewson commented on a diff in the pull request:
https://github.com/apache/couchdb-couch/pull/13#discussion_r19705160
--- Diff: src/couch_db.erl ---
@@ -582,18 +582,27 @@ validate_ddoc(DbName, DDoc) ->
end.
validate_doc_update_int(Db, Doc, GetDiskDocFun) ->
- DiskDoc = GetDiskDocFun(),
- JsonCtx = couch_util:json_user_ctx(Db),
- SecObj = get_security(Db),
- try [case Fun(Doc, DiskDoc, JsonCtx, SecObj) of
- ok -> ok;
- Error -> throw(Error)
- end || Fun <- Db#db.validate_doc_funs],
- ok
- catch
- throw:Error ->
- Error
- end.
+ Fun = fun() ->
+ DiskDoc = GetDiskDocFun(),
+ JsonCtx = couch_util:json_user_ctx(Db),
+ SecObj = get_security(Db),
+ try
+ [case Fun(Doc, DiskDoc, JsonCtx, SecObj) of
+ ok -> ok;
+ Error -> throw(Error)
+ end || Fun <- Db#db.validate_doc_funs],
+ ok
+ catch
+ throw:Error ->
+ Error
+ end
+ end,
+ Begin = os:timestamp(),
--- End diff --
I'd say not in the request_time case given how much code is between start
and end. here we can do `{Duration, Ret} = timer:tc(Fun)`.
I'd even go as far as adding a function for this in couch_stats (which
would call timer:tc) so we could simplify this (and future such stats) to
`couch_stats:update_histogram([couchdb, query_server, vd_process_time], Fun)`.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---