V
V
v- death2015-10-29 20:43:46
go
v- death, 2015-10-29 20:43:46

How does go actually work?

Hello. Here I found a package for encrypting xxtea.
Zayuzal. The first run (example) took 15ms.
Then refreshing the page in the browser and executing the code in 1ms (according to FireBug)
Then I thought that there was some kind of cache, that's all. Added there a variable which I transfer from outside. One fig execution time 1ms - 3ms and this time does not depend on the amount of text.
And if you do not touch this url for a long time, then the first visit to it can be 300ms. And then I shove new data and back 1 - 3 ms
How does Go even work?
Thanks in advance for the answer.
library https://github.com/xxtea/xxtea-go
code

package main

import (
  "fmt"
  "log"
  "microService/libs/httprouter"
  "microService/libs/xxtea"
  "net/http"
)

func main() {
  router := httprouter.New()

  router.GET("/:data", xxteaTest)

  log.Fatal(http.ListenAndServe(":8081", router))
}

func xxteaTest(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
  str := ps.ByName("data")
  key := "o_U*&^(234/]|generals|[24432?>?))"
  encrypt_data := xxtea.Encrypt([]byte(str), []byte(key))
  decrypt_data := string(xxtea.Decrypt(encrypt_data, []byte(key)))

  fmt.Fprint(w, encrypt_data)
  fmt.Fprint(w, "<br><br><br><br><br><br><br><br>")
  fmt.Fprint(w, decrypt_data)

}

request
localhost:8081/%D0%9D%D0%B0%D1%87%D0%BD%D1%83%20%D...,%20%D1%87%D1%82%D0%BE%20%D0%BD%D0%B0%20%D1%80%D0%B8%D1%81%D1%83%D0%BD%D0% BA%D0%B5%20%E2%80%94%20%D1%8D%D1%82%D0%BE%20%D0%BC%D0%BE%D0%B5%20%D1%80%D0% B5%D1%88%D0%B5%D0%BD%D0%B8%D0%B5%20%D0%BF%D0%BE%20%D0%BF%D1%80%D0%BE%D0%B8% D0%B7%D0%B2%D0%BE%D0%B4%D0%B8%D1%82%D0%B5%D0%BB%D1%8C%D0%BD%D0%BE%D1%81%D1% 82%D0%B8.%20%D0%9A%D0%B0%D0%BA%20%D0%B2%D0%B8%D0%B4%D0%B8%D1%82%D0%B5,%20% D0%B8%D0%B3%D1%80%D0%BE%D0%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1%80%D0%BE%D0%B2%D0%BE%D0%B9%20%D0%BF%D1%80% D0%BE%D1%86%D0%B5%D1%81%D1%81.%20%D0%95%D1%81%D0%BB%D0%B8%20%D1%83%D1%87%D0 %B5%D1%81%D1%82%D1%8C,%20%D1%87%D1%82%D0%BE%20%D0%BF%D1%80%D0%B8%20.

The first time worked for 17ms then for 2ms.
Then he left for about 7 minutes. He came and refreshed the page and completed in 300ms. Updated again 3ms.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill, 2015-10-30
@vGrabko99

It's not Go, it's a browser: the first time it reopens the connection, the host resolves, etc., then it works with an already open connection and various caches associated with this request/address. After some inactivity, the connection is closed, the caches are reset, so the request takes longer to process again

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question