<commit_before>%  @copyright 2010-2011 Zuse Institute Berlin
%  @end
%
%   Licensed under the Apache License, Version 2.0 (the "License");
%   you may not use this file except in compliance with the License.
%   You may obtain a copy of the License at
%
%       http://www.apache.org/licenses/LICENSE-2.0
%
%   Unless required by applicable law or agreed to in writing, software
%   distributed under the License is distributed on an "AS IS" BASIS,
%   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%   See the License for the specific language governing permissions and
%   limitations under the License.
%%%-------------------------------------------------------------------
%%% File    bloom_SUITE.erl
%%% @author <NAME> <<EMAIL>>
%%% @doc    Utility functions for execution time measurement.
%%%         Src = http://www.trapexit.org/Measuring_Function_Execution_Time
%%% @end
%%% Created : 01/07/2011 by <NAME> <<EMAIL>>
%%%-------------------------------------------------------------------
%% @version $Id $

-module(measure_util).


-export([time_avg/3]).
-export([print/1, print/2, get/3]).

-type measure_result() :: { Min::non_neg_integer(), 
                            Max::non_neg_integer(),
                            Med::non_neg_integer(), 
                            Avg::non_neg_integer(),
                            Iterations::pos_integer()
                           }.

-type measure_options() :: skip_first_value.

-type time_unit() :: us | ms | s.
-type mr_type() :: min | max | med | avg.

% @doc Measures average execution time with possibiliy of skipping <commit_msg>- measure_util: added time_with_result function<commit_after>%  @copyright 2010-2011 Zuse Institute Berlin
%  @end
%
%   Licensed under the Apache License, Version 2.0 (the "License");
%   you may not use this file except in compliance with the License.
%   You may obtain a copy of the License at
%
%       http://www.apache.org/licenses/LICENSE-2.0
%
%   Unless required by applicable law or agreed to in writing, software
%   distributed under the License is distributed on an "AS IS" BASIS,
%   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%   See the License for the specific language governing permissions and
%   limitations under the License.
%%%-------------------------------------------------------------------
%%% File    bloom_SUITE.erl
%%% @author <NAME> <<EMAIL>>
%%% @doc    Utility functions for execution time measurement.
%%%         Src = http://www.trapexit.org/Measuring_Function_Execution_Time
%%% @end
%%% Created : 01/07/2011 by <NAME> <<EMAIL>>
%%%-------------------------------------------------------------------
%% @version $Id $

-module(measure_util).


-export([time_avg/3, time_with_result/3]).
-export([print/1, print/2, get/3]).

-type measure_result() :: { Min::non_neg_integer(), 
                            Max::non_neg_integer(),
                            Med::non_neg_integer(), 
                            Avg::non_neg_integer(),
                            Iterations::pos_integer()
                           }.

-type measure_options() :: skip_first_value.

-type time_unit() :: us | ms | s.
-type mr_type() :: min | max | med | avg.


time_with_result(Fun, Iterations, Options) ->
    Time = time_avg(Fun, Iterations, Options),
    Result = Fun(),
    {Result, Time}.

% @doc Measures average execution time with possibiliy of skipping 
{'fraction_non_alphanumeric': 0.18900843268391973, 'fraction_numerical': 0.014248328002326258, 'mean_word_length': 2.082437275985663, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7422833', 'n_tokens_mistral': 968, 'n_tokens_neox': 927, 'n_words': 300}