Skip to content

Instantly share code, notes, and snippets.

@kana-sama
Created July 12, 2016 16:07
Show Gist options
  • Save kana-sama/57aaec892b7229a568a609005cb7f483 to your computer and use it in GitHub Desktop.
Save kana-sama/57aaec892b7229a568a609005cb7f483 to your computer and use it in GitHub Desktop.
Summtest
#include <iostream>
#include <chrono>
#include <cmath>
int main() {
double sum;
auto start = std::chrono::system_clock::now();
for (double i = 0; i < 1000000; i++) {
sum += std::sin(i);
}
auto stop = std::chrono::system_clock::now();
auto delta = std::chrono::duration_cast<std::chrono::milliseconds>(stop - start);
std::cout << delta.count();
return 0;
}
package main
import (
"fmt"
"math"
"time"
)
func f() {
var sum float64 = 0
for i := float64(0); i < 1000000; i += 1 {
sum += math.Sin(i)
}
}
func main() {
start := time.Now()
f()
fmt.Println(time.Now().Sub(start))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment