纯文本的状态图及画图工具汇总

发布于 2022-09-22 00:48:54 字数 11545 浏览 242 评论 0

在看文章 golang 中 goroutine 的调度 时,发现里面的几张图,竟然是纯文本画出来的,感觉很有意思,特此 mark 一下,回头也尝试尝试。

状态

       mstart
          |
          v        找不到可执行任务,gc STW,
      +------+     任务执行时间过长,系统阻塞等   +------+
      | spin | ----------------------------> |unspin| 
      +------+          mstop                +------+
          ^                                      |
          |                                      v
      notewakeup <-------------------------  notesleep

状态转换

                                            acquirep(p)        
                          不需要使用的P       P和M绑定的时候       进入系统调用       procresize()
new(p)  -----+        +---------------+     +-----------+     +------------+    +----------+
            |         |               |     |           |     |            |    |          |
            |   +------------+    +---v--------+    +---v--------+    +----v-------+    +--v---------+
            +-->|  _Pgcstop  |    |    _Pidle  |    |  _Prunning |    |  _Psyscall |    |   _Pdead   |
                +------^-----+    +--------^---+    +--------^---+    +------------+    +------------+
                       |            |     |            |     |            |
                       +------------+     +------------+     +------------+
                           GC结束            releasep()        退出系统调用
                                            P和M解绑                      

G 的状态图

                                                      +------------+
                                      ready           |            |
                                  +------------------ |  _Gwaiting |
                                  |                   |            |
                                  |                   +------------+
                                  |                         ^ park_m
                                  V                         | 
  +------------+            +------------+  execute   +------------+            +------------+    
  |            |  newproc   |            | ---------> |            |   goexit   |            |
  |  _Gidle    | ---------> | _Grunnable |  yield     | _Grunning  | ---------> |   _Gdead   |      
  |            |            |            | <--------- |            |            |            |
  +------------+            +-----^------+            +------------+            +------------+
                                  |         entersyscall |      ^ 
                                  |                      V      | existsyscall
                                  |                   +------------+
                                  |   existsyscall    |            |
                                  +------------------ |  _Gsyscall |
                                                      |            |
                                                      +------------+

AsciiFlow:在线流程图绘制平台是一个强大的在线 ASCII 图形绘制工具,ASCIIFlow 是上世纪九十年代黑客们最爱的制作流程图表方式,全文本易传播,Geek 风格的反璞归真。不幸的是,目前似乎无法输入中文。

支持中文版本修改版本asciiflow

把 Ascii 图转换为手绘图的命令行工具.

录制终端命令执行的工具,asciinema,例如:

asciicast

plantuml 的状态图

@startuml

[*] --> State1
State1 --> [*]
State1 : this is a string
State1 : this is another string

State1 -> State2
State2 --> [*]

@enduml

在线转换

github 使用 plantuml

1、创建单独的文件 rpc.txt,加入路径为 wmenjoy/awesome-knowleges/master/nio/rpc.txt 简单的例子如下

@startuml
class VersionableObject{
    + String  version;
    + String key;
    + V value;

}


class ConfigCenter{
  + String getVersion(String key)
  + V getValue(String key)
  + boolean update(key, V value)
}
ConfigCenter --> VersionableObject
@enduml

2、使用

![uncached image](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/wmenjoy/awesome-knowleges/master/nio/rpc.txt)

效果如下

uncached image

使用强大的 Gravizo - Your Graphviz, UMLGraph or PlantUML

<img src='https://g.gravizo.com/svg?
 digraph G {
   main -> parse -> execute;
   main -> init;
   main -> cleanup;
   execute -> make_string;
   execute -> printf
   init -> make_string;
   main -> printf;
   execute -> compare;
 }
'/>

<img src='https://g.gravizo.com/svg?
@startuml;

actor User;
participant "First Class" as A;
participant "Second Class" as B;
participant "Last Class" as C;

User -> A: DoWork;
activate A;

A -> B: Create Request;
activate B;

B -> C: DoWork;
activate C;

C --> B: WorkDone;
destroy C;

B --> A: Request Created;
deactivate B;

A --> User: Done;
deactivate A;

@enduml
'>
    

go list generating dependency graphs

(   echo "digraph G {"
    go list -f '{{range .Imports}}{{printf "\t%q -> %q;\n" $.ImportPath .}}{{end}}' \
        $(go list -f '{{join .Deps " "}}' time) time
    echo "}"
)

bpmn-js BPMN 2.0 rendering toolkit and web modeler. 一个在线绘制业务流程图的开源工具。

ASCII Art Girl

package main

import (
	"bytes"
	"compress/zlib"
	"encoding/base64"
	"io"
	"os"
)

func main() {
	tryme := `eJydlM1qxCAQgO95iiCU7MJmLD0WQqGXXvoIAU0bYaXLVmqgPfThd6L5GROzdetlR+P3jcmMm6eOQ1kxxirIEvdDMUYyldnRSTKFO8NZMpgfpjMOR04mw5xFekpES8ri7AYWxz6UVbfxc1X+w4NcLVzHxWZ5+1FffXtXHPqd55j7sN5ieaRMtf/5HVe3+ivsiUngPvvgdap4cr8Dijmxjxze556WYrzP7WtEji7Ba4dXGB6uBRRfN2lo6MOlYclHHUSBz0KFEyxbLCIhPbzPd0LQUjjHqlViHmKRgP9N4+0VULojCBHelagHo9eXZ09KdDD21/XFTP3Ijl1n7CPnjX3Xuvnq4Fu9Wd0prs+t+gFzNE+4Whn1aU6Kn5sP1d493J+aViubXQDvoM84`

	r0 := bytes.NewBufferString(tryme)
	r1 := base64.NewDecoder(base64.StdEncoding, r0)
	r2, _ := zlib.NewReader(r1)
	io.Copy(os.Stdout, r2)
	r2.Close()
}
$ go run hello.go
                                         ,-="""=.
                                       .'        `.
                                      (            `.
                                       `.            `..
                                        ,'             .'
                                        `.            '.
                                          `-.           `-.
                                             )             `=-.
                                           .'              `=-.
                                         .`               .`-.
                           _            (                \ `-.
                        ,'   `.          `.        /`.    \
                       /        `.         \      |   `.   `.
                     ,'            `.       )    /      \    \
                    /     .'`.        `.    )    |       `.   \
                  ,'    .'    `.         `./     \         `.  \
                ,'    .'        `.                \          \  \
              ,'    .'            `.               \          `. \
            ,'   .'                 `.              )          ) (__.
          ,'   (                      `.            )          `."""'
      _.-'    __)                       `.         .  LGB
     `""'""                               `"""""""
https://asciiart.website/index.php?art=people/naked%20ladies

手绘形状的图

seqdiag 时序图

https://github.com/seaweedfs/fuse/blob/master/doc/mount-osx.seq

http://blockdiag.com/en/seqdiag/index.html

cloudcraft 一个网页工具,用来画网络架构图。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

关于作者

青衫负雪

暂无简介

文章
评论
26 人气
更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文