我们之所以觉得悬崖上的花朵美丽,那是因为我们会在悬崖停下脚步,而不是像那些毫不畏惧的花朵般,能向天空踏出一步。- 死神
 
#  Python 
1 2 3 4 5 6 7 8 import  timen = 1  start = time.time() while  n < 100000000 :    n = n + 1  end = time.time() print((end - start) * 1000 ) 
 
#  PHP 
1 2 3 4 5 6 7 8 9 <?php $n  = 1 ;$start  = time();while  ($n  < 100000000 ) {    $n  = $n  + 1 ; } $end  = time()echo  ($end  - $start ) * 1000 ;
 
#  JavaScript 
1 2 3 4 5 6 7 let  n = 1 ;const  start = Date .now();while  (n < 100000000 ) {    n = n + 1 ; } const  end = Date .now();console .log(end - start);
 
#  C# 
csc Test.cs => ./Test.exe
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 using  System;namespace  Application {    class  Test     {       static  void  Main (string [] args )        {         DateTime start = System.DateTime.Now;          int  n = 1 ;          while  (n < 100000000 ) {             n = n + 1 ;          }          DateTime end = System.DateTime.Now;          TimeSpan ts = end.Subtract(start);          Console.WriteLine("{0}ms" , ts.TotalMilliseconds);       }    } } 
 
#  Java 
javac Test.java => java Test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import  java.time.Instant;import  java.time.Duration;class  Test  {    public  static  void  main (String[] args)   {         Instant start = Instant.now();                           int  n = 1 ;         while  (n < 100000000 ) {             n = n + 1 ;         }         Instant end = Instant.now();         System.out.println(Duration.between(start, end).toMillis());     } } 
 
gcc test.c -o testc.exe -> ./testc.exe
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include  <time.h>  #include  <stdio.h>  #include  <stdlib.h>  int  main ()  {    time_t  c_start, c_end;     c_start = clock();     int  n = 1 ;     while  (n < 100000000 )     {         n = n + 1 ;     }     c_end = clock();     printf ("%f" , difftime(c_end, c_start)); } 
 
#  C++ 
g++ test.cpp -o testcpp.exe -> ./testcpp.exe
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #include  <time.h>  #include  <iostream>  using  namespace  std ;int  main ()  {    time_t  c_start, c_end;     c_start = clock();     int  n = 1 ;     while  (n < 100000000 )     {         n = n + 1 ;     }     c_end = clock();     cout  << difftime(c_end, c_start) << endl ; } 
 
#  Go 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 package  mainimport  (	"fmt"  	"time"  ) func  main ()   {	start := time.Now() 	for  n := 1 ; n < 100000000 ; { 		n = n + 1  	} 	elapsed := time.Since(start) 	fmt.Println(elapsed) } 
 
#  PL/SQL 
PL/SQL Developer -> Execute
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 declare    l_start   date ;   l_count   number;   l_elapsed number; begin    l_count :=  1 ;    l_start :=  sysdate;       while l_count <  100000000     loop       l_count :=  l_count +  1 ;    end  loop;        l_elapsed :=  (sysdate -  l_start) *  24  *  60  *  60 ;        dbms_output.put_line(l_elapsed ||  's' ); end ;
 
#  VBA 
1 2 3 4 5 6 7 8 9 10 11 12 13 Sub CostTime()     Dim n As Long, start As Single          n = 1     start = Timer          While n < 100000000:         n = n + 1     Wend          Debug.Print (Timer - start) * 1000 	' MsgBox (Timer - start) * 1000 End Sub