forked from RedHatOfficial/GoCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlesson9_ru.slide
More file actions
71 lines (48 loc) · 2.23 KB
/
lesson9_ru.slide
File metadata and controls
71 lines (48 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Урок 9. Оптимизации в Go
Lesson 9
27 Jul 2025
Tags: golang, go
Перевод команды GoCourse
Pavel Tišnovský
Red Hat, Inc.
https://github.com/RedHatOfficial/GoCourse
@RedHat
* Источники
- [[https://github.com/RedHatOfficial/GoCourse]]
.image ./common/qr_address.png
* Gophers
#The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
#Source https://golang.org/doc/gopher/fiveyears.jpg
#The design and this image is licensed under the Creative Commons 3.0 Attributions license.
.image ./common/fiveyears.jpg _ 900
* Оптимизации в Go
- передавать структуры по ссылке, а не по значению
* Передавать структуры по ссылке, а не по значению
- все типы данных передаются по значению в функции и методы
- это хорошо с точки зрения "пространства состояний"
- не так хорошо с точки зрения производительности
- (и нет удобного решения как `const` и `mut` в Go)
* Определение проблемы
- Большие структуры передаются по значению везде в коде
- Даже во внутренних циклах
- Это вызывает накладные расходы, которых легко избежать
* Реальный пример
.code optimizations/config_struct_1.go
* Реальный пример
.code optimizations/config_struct_2.go
* Реальный пример
.code optimizations/config_struct_3.go
* Стоит ли это делать?
.play optimizations/benchmark_1_1.go
* Стоит ли это делать?
.play optimizations/benchmark_1_2.go
* Стоит ли это делать?
.play optimizations/benchmark_1_3.go
* Стоит ли это делать?
.play optimizations/benchmark_1_4.go
#last slide
* Больше Gophers
#The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
#Source https://golang.org/doc/gopher/bumper.png
#The design and this image is licensed under the Creative Commons 3.0 Attributions license.
.image ./common/bumper.png _ 900