Github user davisp commented on the issue:

    https://github.com/apache/couchdb-couch/pull/217
  
    Here's a micro benchmark that shows a significant speedup for the new 
version. Between 1,000% and 6,000% depending on whether it actually has to 
remove the suffix.
    
    ```erlang
    -module(benchmark).
    
    -export([
        go/0,
        drop_dot_couch_ext/1,
        maybe_remove_extension/1
    ]).
    
    
    
    -define(TEST_1, 
<<"shards/00000000-1fffffff/example/c28fb579-0a4c-4421-8d44-65a7650b6da0.1475265285">>).
    -define(TEST_2, 
<<"shards/00000000-1fffffff/example/c28fb579-0a4c-4421-8d44-65a7650b6da0.1475265285.couch">>).
    
    
    go() ->
        Tests = [
                fun() -> run_drop(?TEST_1, 1000) end,
                fun() -> run_drop(?TEST_2, 1000) end,
                fun() -> run_maybe(?TEST_1, 1000) end,
                fun() -> run_maybe(?TEST_2, 1000) end
        ],
        lists:foreach(fun(T) ->
                R = timer:tc(T),
                io:format("~p~n", [R])
        end, Tests).
    
    
    run_drop(_Test, 0) ->
        ok;
    
    run_drop(Test, Count) ->
        ?TEST_1 = drop_dot_couch_ext(Test),
        run_drop(Test, Count - 1).
    
    
    run_maybe(_Test, 0) ->
        ok;
    
    run_maybe(Test, Count) ->
        ?TEST_1 = maybe_remove_extension(Test),
        run_maybe(Test, Count - 1).
    
    
    drop_dot_couch_ext(DbName) when is_binary(DbName) ->
        PrefixLen = size(DbName) - 6,
        case DbName of
            <<Prefix:PrefixLen/binary, ".couch">> ->
                Prefix;
            Else ->
                Else
        end;
    
    drop_dot_couch_ext(DbName) when is_list(DbName) ->
        binary_to_list(drop_dot_couch_ext(iolist_to_binary(DbName))).
    
    
    maybe_remove_extension(DbName) ->
        case filename:extension(DbName) of
            <<".couch">> ->
                filename:rootname(DbName);
            _ ->
                DbName
        end.
    ```
    
    ```
    Eshell V6.4.1.5  (abort with ^G)
    1> benchmark:go().
    {141,ok}
    {124,ok}
    {1285,ok}
    {5673,ok}
    ok
    ```


---
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.
---

Reply via email to