-
-
Save bobrik/2c1a8a19b921fefe22caac21fda1be82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io" | |
"log" | |
"net/http" | |
"time" | |
) | |
func main() { | |
go massageBallast() | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
resp, err := http.Get("https://sim.cfperf.net/cached-assets/zero-5g.bin") | |
if err != nil { | |
log.Fatalf("Error sending a request: %v", err) | |
} | |
defer resp.Body.Close() | |
n, err := io.Copy(w, resp.Body) | |
if err != nil { | |
log.Fatalf("Error copying response body: %v", err) | |
} | |
log.Printf("Copied %d bytes", n) | |
}) | |
err := http.ListenAndServe(":4444", nil) | |
if err != nil { | |
log.Fatalf("Error listening: %v", err) | |
} | |
} | |
func massageBallast() { | |
ballast := make([]uint8, 4*1024*1024*1024) | |
for i := range ballast { | |
ballast[i] = uint8(i % 8) | |
} | |
for { | |
sum := 0 | |
for _, b := range ballast { | |
sum += int(b) | |
} | |
time.Sleep(1 * time.Second) | |
log.Printf("sum = %d", sum) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment