ADT
        aaron-thesis
        arm-eh
        ast-experimental
        cleanup-dtors
        deferred_resn
        demangler
        enum
        forall-pointer-decay
        jacob/cs343-translation
        jenkins-sandbox
        new-ast
        new-ast-unique-expr
        new-env
        no_list
        persistent-indexer
        pthread-emulation
        qualifiedEnum
        with_gc
      
      
        
          | 
            Last change
 on this file since ef952d7 was             50abab9, checked in by Thierry Delisle <tdelisle@…>, 8 years ago           | 
        
        
          | 
             
Added benchmarks for java and go 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            638 bytes
           | 
        
      
      
| Rev | Line |   | 
|---|
| [50abab9] | 1 | package main
 | 
|---|
 | 2 | 
 | 
|---|
 | 3 | import (
 | 
|---|
 | 4 |     "fmt"
 | 
|---|
 | 5 |     "runtime"
 | 
|---|
 | 6 |     "time"
 | 
|---|
 | 7 | )
 | 
|---|
 | 8 | 
 | 
|---|
 | 9 | //=======================================
 | 
|---|
 | 10 | // time context switch
 | 
|---|
 | 11 | //=======================================
 | 
|---|
 | 12 | 
 | 
|---|
 | 13 | var shake chan bool = make( chan bool )
 | 
|---|
 | 14 | 
 | 
|---|
 | 15 | func ContextSwitch(N int) {
 | 
|---|
 | 16 |         start := time.Now()
 | 
|---|
 | 17 |         for i := 1; i <= N; i += 1 {
 | 
|---|
 | 18 |                 runtime.Gosched()
 | 
|---|
 | 19 |         }
 | 
|---|
 | 20 |         end := time.Now()
 | 
|---|
 | 21 |         fmt.Printf("%d\n", end.Sub(start) / time.Duration(N))
 | 
|---|
 | 22 |         shake <- true   // indicate completion
 | 
|---|
 | 23 | }
 | 
|---|
 | 24 | 
 | 
|---|
 | 25 | //=======================================
 | 
|---|
 | 26 | // benchmark driver
 | 
|---|
 | 27 | //=======================================
 | 
|---|
 | 28 | 
 | 
|---|
 | 29 | func main() {
 | 
|---|
 | 30 |         const NoOfTimes = 10000000
 | 
|---|
 | 31 |         go ContextSwitch( NoOfTimes )           // context switch
 | 
|---|
 | 32 |         <- shake
 | 
|---|
 | 33 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.