How to find execution time of classification algorithms in R? [duplicate]











up vote
0
down vote

favorite













This question already has an answer here:




  • get execution time in milliseconds in R

    3 answers




I am running a naive bayes classifcation algorithm in R. I want to calculate the execution time of the algorithm.
Shall i use



Start_time <- proc.time()
{
#execution of naive bayes classifier
}
End_time <- proc_time()
Exec_time = End_time - Start_time


to find the execution time.
Is it the right way to calculate the execution time of an algorithm?










share|improve this question















marked as duplicate by Henrik r
Users with the  r badge can single-handedly close r questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 at 20:52


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















    up vote
    0
    down vote

    favorite













    This question already has an answer here:




    • get execution time in milliseconds in R

      3 answers




    I am running a naive bayes classifcation algorithm in R. I want to calculate the execution time of the algorithm.
    Shall i use



    Start_time <- proc.time()
    {
    #execution of naive bayes classifier
    }
    End_time <- proc_time()
    Exec_time = End_time - Start_time


    to find the execution time.
    Is it the right way to calculate the execution time of an algorithm?










    share|improve this question















    marked as duplicate by Henrik r
    Users with the  r badge can single-handedly close r questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Nov 21 at 20:52


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite












      This question already has an answer here:




      • get execution time in milliseconds in R

        3 answers




      I am running a naive bayes classifcation algorithm in R. I want to calculate the execution time of the algorithm.
      Shall i use



      Start_time <- proc.time()
      {
      #execution of naive bayes classifier
      }
      End_time <- proc_time()
      Exec_time = End_time - Start_time


      to find the execution time.
      Is it the right way to calculate the execution time of an algorithm?










      share|improve this question
















      This question already has an answer here:




      • get execution time in milliseconds in R

        3 answers




      I am running a naive bayes classifcation algorithm in R. I want to calculate the execution time of the algorithm.
      Shall i use



      Start_time <- proc.time()
      {
      #execution of naive bayes classifier
      }
      End_time <- proc_time()
      Exec_time = End_time - Start_time


      to find the execution time.
      Is it the right way to calculate the execution time of an algorithm?





      This question already has an answer here:




      • get execution time in milliseconds in R

        3 answers








      r execution-time






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 at 19:01









      42-

      210k14249394




      210k14249394










      asked Nov 21 at 18:37









      raji sadhu

      11




      11




      marked as duplicate by Henrik r
      Users with the  r badge can single-handedly close r questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 21 at 20:52


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Henrik r
      Users with the  r badge can single-handedly close r questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 21 at 20:52


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          You can use package microbenchmark or rbenchmark to test code.



          First define a function:



          myfunction <- function(){}


          then define how many times should run the function



          n <- 10


          Here is an example using microbenchmark:



          microbenchmark::microbenchmark(myfunction(),times=n) #run your function "n" times


          Here is an example using rbenchmark:



          rbenchmark::benchmark(myfunction(),replications=n) #run your function "n" times


          For both packages you can get the result using operator <-. For example:



          microbenchmark::microbenchmark(a<-myfunction(),times=n) # result is in variable "a"
          rbenchmark::rbenchmark(a<-myfunction(),times=n) # result is in variable "a"





          share|improve this answer




























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            You can use package microbenchmark or rbenchmark to test code.



            First define a function:



            myfunction <- function(){}


            then define how many times should run the function



            n <- 10


            Here is an example using microbenchmark:



            microbenchmark::microbenchmark(myfunction(),times=n) #run your function "n" times


            Here is an example using rbenchmark:



            rbenchmark::benchmark(myfunction(),replications=n) #run your function "n" times


            For both packages you can get the result using operator <-. For example:



            microbenchmark::microbenchmark(a<-myfunction(),times=n) # result is in variable "a"
            rbenchmark::rbenchmark(a<-myfunction(),times=n) # result is in variable "a"





            share|improve this answer

























              up vote
              0
              down vote













              You can use package microbenchmark or rbenchmark to test code.



              First define a function:



              myfunction <- function(){}


              then define how many times should run the function



              n <- 10


              Here is an example using microbenchmark:



              microbenchmark::microbenchmark(myfunction(),times=n) #run your function "n" times


              Here is an example using rbenchmark:



              rbenchmark::benchmark(myfunction(),replications=n) #run your function "n" times


              For both packages you can get the result using operator <-. For example:



              microbenchmark::microbenchmark(a<-myfunction(),times=n) # result is in variable "a"
              rbenchmark::rbenchmark(a<-myfunction(),times=n) # result is in variable "a"





              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                You can use package microbenchmark or rbenchmark to test code.



                First define a function:



                myfunction <- function(){}


                then define how many times should run the function



                n <- 10


                Here is an example using microbenchmark:



                microbenchmark::microbenchmark(myfunction(),times=n) #run your function "n" times


                Here is an example using rbenchmark:



                rbenchmark::benchmark(myfunction(),replications=n) #run your function "n" times


                For both packages you can get the result using operator <-. For example:



                microbenchmark::microbenchmark(a<-myfunction(),times=n) # result is in variable "a"
                rbenchmark::rbenchmark(a<-myfunction(),times=n) # result is in variable "a"





                share|improve this answer












                You can use package microbenchmark or rbenchmark to test code.



                First define a function:



                myfunction <- function(){}


                then define how many times should run the function



                n <- 10


                Here is an example using microbenchmark:



                microbenchmark::microbenchmark(myfunction(),times=n) #run your function "n" times


                Here is an example using rbenchmark:



                rbenchmark::benchmark(myfunction(),replications=n) #run your function "n" times


                For both packages you can get the result using operator <-. For example:



                microbenchmark::microbenchmark(a<-myfunction(),times=n) # result is in variable "a"
                rbenchmark::rbenchmark(a<-myfunction(),times=n) # result is in variable "a"






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 21 at 19:48









                Csd

                29819




                29819















                    Popular posts from this blog

                    Berounka

                    Different font size/position of beamer's navigation symbols template's content depending on regular/plain...

                    Sphinx de Gizeh