Skip to content

Commit b9486b1

Browse files
committed
Fix typos.
1 parent 49418e6 commit b9486b1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

_posts/blog/2015-09-27-surprises-in-gopherjs-performance.mdown

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
layout: post
3-
title: "Surprises in GohperJS Performance"
3+
title: "Surprises in GopherJS Performance"
44
date: 2015-09-27
55
author: Dmitri Shuralyov
66
---
77

8-
The GohperJS project first caught my attention about 2 year ago, back when few parts of the Go spec were implemented.
8+
The GopherJS project first caught my attention about 2 year ago, back when few parts of the Go spec were implemented.
99
However, I noticed the incredible pace at which Richard was working, making multiple sophisticated commits per day, as well as fixing reported compiler issues within hours.
1010
A few months later, I decided to download it and give it try on a relatively [large pure Go package](https://godoc.org/github.com/shurcooL/markdownfmt/markdown?import-graph&hide=1) for formatting Markdown, and I was quite shocked when it... [simply worked](https://github.com/shurcooL/atom-markdown-format/commit/6b5f21c4457309f8eba3a78b82e0c9a458ff13b4).
1111

@@ -65,7 +65,7 @@ total time taken is: 8.358498915s
6565
Then I got curious how long it would take if compiled to JavaScript via GopherJS.
6666

6767
I realized that this is a very tight loop, so any overhead incurred by the conversion of Go to JavaScript would be multiplied and be very visible.
68-
Still, I was curious, so fired up GohperJS and ran the same program by compiling it to JavaScript and running it with node:
68+
Still, I was curious, so fired up GopherJS and ran the same program by compiling it to JavaScript and running it with node:
6969

7070
```bash
7171
$ gopherjs run main.go
@@ -91,14 +91,16 @@ And got the same time in Chrome browser (stable channel).
9191

9292
The calculated value of pi was the same, and after adding some debugging statements I was sure the calculation was indeed correct, and iterations were not being skipped.
9393

94-
But how could it be that taking this Go program and compiling it to JavaScript and executing that would be 4 times faster? I had to get to the bottom of it.
94+
But how could it be that taking this Go program and compiling it to JavaScript and executing that would be 4 times faster?
95+
I had to get to the bottom of it.
9596

96-
The first thing I needed to ensure, was the same code being run in both cases? The entire code is plain Go, with the exception of `math.Pow`.
97+
The first thing I needed to ensure, was the same code being run in both cases?
98+
The entire code is plain Go, with the exception of `math.Pow`.
9799
So I looked at how [Go implements it](http://gotools.org/math#Pow).
98100
Pretty straightforward Go code.
99101
Now I knew GopherJS uses some JavaScript native APIs to implement parts of the standard library, so I checked how [it implemented `math.Pow`](https://github.com/gopherjs/gopherjs/blob/master/compiler/natives/math/math.go#L157).
100102
Aha! It's not the same code after all.
101-
GohperJS implements it by using [JavaScript's `Math` object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math), so it translates to:
103+
GopherJS implements it by using [JavaScript's `Math` object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math), so it translates to:
102104

103105
```JavaScript
104106
Math.pow(x, y)
@@ -233,7 +235,8 @@ user 0m11.377s
233235
sys 0m0.006s
234236
```
235237

236-
11.3 seconds? Slower? Ah, of course, I was too used to `go` build tool that uses optimization by default, and forgot that C compilers don't do that.
238+
11.3 seconds? Slower?
239+
Ah, of course, I was too used to `go` build tool that uses optimization by default, and forgot that C compilers don't do that.
237240

238241
```bash
239242
$ gcc -O3 main.c

0 commit comments

Comments
 (0)