mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-12 01:40:10 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
30cd5f9755
@ -1,81 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How JavaScript became a serious programming language)
|
||||
[#]: via: (https://opensource.com/article/20/10/history-javascript)
|
||||
[#]: author: (Nimisha Mukherjee https://opensource.com/users/nimisha)
|
||||
|
||||
How JavaScript became a serious programming language
|
||||
======
|
||||
From humble beginnings as a way to make websites pretty, JavaScript has
|
||||
been transformed into a serious programming language.
|
||||
![Javascript code close-up with neon graphic overlay][1]
|
||||
|
||||
JavaScript's humble start began in 1995, when it was [created in just 10 days][2] by Brendan Eich, then an employee with Netscape Communications Corporation. JavaScript has come a long way since then, from a tool to make websites pretty to a serious programming language.
|
||||
|
||||
In its early days, JavaScript was considered a visual tool that made websites a little more fun and attractive. Languages like [Jakarta Server Pages][3] (JSP; formerly JavaServer Pages) used to do all the heavy lifting on rendered web pages, and JavaScript was used to create basic interactions, visual enhancements, and animations.
|
||||
|
||||
For a long time, the demarcations between HTML, CSS, and JavaScript were not clear. Frontend development primarily consists of HTML, CSS, and JavaScript, forming a "[layer cake][4]" of standard web technologies.
|
||||
|
||||
![Layer cake of standard web technologies][5]
|
||||
|
||||
The "[layer cake][4]" of standard web technologies (Mozilla Developers Network, [CC BY-SA 4.0][6])
|
||||
|
||||
HTML and CSS provide structure, format, and style to content. JavaScript comes into play once a web page does something beyond displaying static content. Ecma International develops JavaScript specifications, and the World Wide Web Consortium (W3C) develops HTML and CSS specifications.
|
||||
|
||||
### How JavaScript gained prominence
|
||||
|
||||
There is a long [history][7] behind how JavaScript came to be the [most popular][8] programming language. Back in the 1990s, Java was king, and comparisons to it were inevitable. Many engineers thought JavaScript was not a good programming language due to lack of support for object-oriented programming. Even though it was not evident, JavaScript's object-model and functional features were already present in its first version.
|
||||
|
||||
After JavaScript's rushed release in 1995, Netscape submitted it to the European Computer Manufacturers Association (ECMA) International for standardization. This led to [ECMAScript][9], a JavaScript standard meant to ensure interoperability of web pages across different web browsers. ECMAScript 1 came out in June 1997 and helped to advance the standardization of JavaScript.
|
||||
|
||||
During this time, PHP and JSP became popular server-side language choices. JSP had gained prominence as the preferred alternative to Common Gateway Interface ([CGI][10]) because it enabled embedding Java code in HTML. While it was popular, developers found it unnatural to have Java inside HTML. In addition, even for the simplest text change on HTML, JSP had to undergo a time-consuming lifecycle. In today's microservice world, JSP-oriented pages are considered technical debt.
|
||||
|
||||
[PHP][11] works similarly to JSP but the PHP code is processed as a Common Gateway Interface ([CGI][10]) executable. PHP-based web applications are easier to deploy than those based on JSP. Overall, it is easier to get up and running with PHP. Today, PHP and JavaScript are one of the most popular combinations for creating dynamic websites. PHP serves as the server-side scripting and JavaScript as the client-side scripting.
|
||||
|
||||
JavaScript's adoption grew with the release of [jQuery][12], a multi-purpose JavaScript library that simplifies tedious Document Object Model (DOM) management, event handling, and [Ajax][13], in 2006.
|
||||
|
||||
The turning point for JavaScript came in 2009 when [Node.js][14] was released. Developers could now write server-side scripting with JavaScript. Closely following were frameworks like [Backbone.js][15] and [AngularJS][16], both released in 2010. This led to the concept of full-stack development using a single language.
|
||||
|
||||
In 2015, Ecma International released ECMAScript 6 (ES6), which added significant new syntax for writing complex applications, including class declarations. Other new features included iterators, arrow function expressions, let and const keywords, typed arrays, new collections (maps, sets, and WeakMap), promises, template literals for strings, and many other cool features. Later editions have gone on to add more features that have made JavaScript more robust, streamlined, and reliable.
|
||||
|
||||
### Conclusion
|
||||
|
||||
JavaScript has advanced significantly over the past two decades. Most browsers now compete to meet compliance, so the latest specifications are rolled out faster.
|
||||
|
||||
There are a host of stable JavaScript frameworks to choose from, depending on your project requirements, including the most popular ones: [React][17], [Angular][18], and [Vue.js][19]. In the next article in this series, I'll dive into why JavaScript is so popular.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/10/history-javascript
|
||||
|
||||
作者:[Nimisha Mukherjee][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/nimisha
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_javascript.jpg?itok=60evKmGl (Javascript code close-up with neon graphic overlay)
|
||||
[2]: https://en.wikipedia.org/wiki/JavaScript
|
||||
[3]: https://en.wikipedia.org/wiki/Jakarta_Server_Pages
|
||||
[4]: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript
|
||||
[5]: https://opensource.com/sites/default/files/uploads/layercakewebtech.png (Layer cake of standard web technologies)
|
||||
[6]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[7]: https://blog.logrocket.com/history-of-frontend-frameworks/
|
||||
[8]: https://octoverse.github.com/
|
||||
[9]: https://en.wikipedia.org/wiki/ECMAScript
|
||||
[10]: https://en.wikipedia.org/wiki/Common_Gateway_Interface
|
||||
[11]: https://en.wikipedia.org/wiki/PHP#:~:text=PHP%20development%20began%20in%201994,Interpreter%22%20or%20PHP%2FFI.
|
||||
[12]: https://en.wikipedia.org/wiki/JQuery
|
||||
[13]: https://en.wikipedia.org/wiki/Ajax_(programming)
|
||||
[14]: https://en.wikipedia.org/wiki/Node.js
|
||||
[15]: https://en.wikipedia.org/wiki/Backbone.js
|
||||
[16]: https://en.wikipedia.org/wiki/AngularJS
|
||||
[17]: https://reactjs.org/
|
||||
[18]: https://angular.io/
|
||||
[19]: https://vuejs.org/
|
@ -1,113 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (xiao-song-123)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Understand your Python code with this open source visualization tool)
|
||||
[#]: via: (https://opensource.com/article/20/11/python-code-viztracer)
|
||||
[#]: author: (Tian Gao https://opensource.com/users/gaogaotiantian)
|
||||
|
||||
Understand your Python code with this open source visualization tool
|
||||
======
|
||||
VizTracer visualizes and traces Python code to provide greater insight
|
||||
into how the code works.
|
||||
![Python programming language logo with question marks][1]
|
||||
|
||||
It's challenging to understand your Python project as it gets larger and more complex. Even when you write the entire project, it's impossible to know how it works fully. Debugging and profiling your code is essential to better understanding it.
|
||||
|
||||
[VizTracer][2] is a tool to help you understand Python code by tracing and visualizing its execution. Without making any changes to your source code, VizTracer can log function entries/exits, function arguments/returns, and any arbitrary variables, then display the data using an intuitive front-end Google [Trace-Viewer][3].
|
||||
|
||||
Here is an example of running a [Monte Carlo tree search][4]:
|
||||
|
||||
![Monte Carlo tree search visualization][5]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][6])
|
||||
|
||||
Every function is logged and visualized in stack style on a timeline so that you can see what is happening when you run a program. You can zoom in to see the details at any specific point:
|
||||
|
||||
![Zooming in on VizTracer visualization][7]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][6])
|
||||
|
||||
VizTracer can also automatically log function arguments and return value; you can click on the function entry and see the detail info:
|
||||
|
||||
![Viewing VizTracer details][8]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][6])
|
||||
|
||||
Or you can create a whole new signal and use it to log variables. For example, this shows the cost value when you do a gradient descent:
|
||||
|
||||
![VizTracer gradient descent][9]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][6])
|
||||
|
||||
In contrast to other tools with complicated setups, VizTracer is super-easy to use and does not have any dependencies. You can install it from pip with:
|
||||
|
||||
|
||||
```
|
||||
`pip install viztracer`
|
||||
```
|
||||
|
||||
And trace your program by entering (where `<your_script.py>` is the name of your script):
|
||||
|
||||
|
||||
```
|
||||
`viztracer <your_script.py>`
|
||||
```
|
||||
|
||||
VizTracer will generate an HTML report in your working directory that you can open in Chrome.
|
||||
|
||||
VizTracer offers other advanced features, such as filters, which you can use to filter out the functions that you do not want to trace so that you'll have a cleaner report. For example, to include only the functions in files, you are interested in:
|
||||
|
||||
|
||||
```
|
||||
`viztracer include_files ./ --run <your_script.py>`
|
||||
```
|
||||
|
||||
To record the function arguments and return value:
|
||||
|
||||
|
||||
```
|
||||
`viztracer --log_function_args --log_return_value <your_script.py>`
|
||||
```
|
||||
|
||||
To log any arbitrary variables matching a certain regex:
|
||||
|
||||
|
||||
```
|
||||
# log variables starts with a
|
||||
viztracer --log_var a.* --run <your_script.py>
|
||||
```
|
||||
|
||||
You can get other features, like custom events to log numeric values and objects, by making minor modifications to your source code.
|
||||
|
||||
VizTracer also includes a virtual debugger (vdb) that can debug VizTracer's log file. vdb debugs your executed code (much like [pdb][10]) so that you can understand the code flow. Helpfully, it supports running back in time because it knows everything that happened.
|
||||
|
||||
Unlike some prototypes, VizTracer implements its core in pure C, which significantly reduces the overhead to a level similar to [cProfile][11].
|
||||
|
||||
VizTracer is open source, released under the Apache 2.0 License, and supports all common operating systems platforms (Linux, macOS, and Windows). You can learn more about its features and access its source code on [GitHub][2].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/11/python-code-viztracer
|
||||
|
||||
作者:[Tian Gao][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/gaogaotiantian
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python_programming_question.png?itok=cOeJW-8r (Python programming language logo with question marks)
|
||||
[2]: https://github.com/gaogaotiantian/viztracer
|
||||
[3]: http://google.github.io/trace-viewer/
|
||||
[4]: https://en.wikipedia.org/wiki/Monte_Carlo_tree_search
|
||||
[5]: https://opensource.com/sites/default/files/uploads/viztracer_mcts.png (Monte Carlo tree search visualization)
|
||||
[6]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[7]: https://opensource.com/sites/default/files/uploads/viztracer_zoomin.png (Zooming in on VizTracer visualization)
|
||||
[8]: https://opensource.com/sites/default/files/uploads/viztracer_details.png (Viewing VizTracer details)
|
||||
[9]: https://opensource.com/sites/default/files/uploads/viztracer_gradient.png (VizTracer gradient descent)
|
||||
[10]: https://docs.python.org/3/library/pdb.html
|
||||
[11]: https://docs.python.org/2/library/profile.html#module-cProfile
|
@ -0,0 +1,82 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How JavaScript became a serious programming language)
|
||||
[#]: via: (https://opensource.com/article/20/10/history-javascript)
|
||||
[#]: author: (Nimisha Mukherjee https://opensource.com/users/nimisha)
|
||||
|
||||
JavaScript 是如何成为一门严肃的编程语言的
|
||||
======
|
||||
|
||||
> 从最开始作为一种使网站变得漂亮的方式,JavaScript 已转变为一种严肃的编程语言。
|
||||
|
||||
![Javascript 代码特写与霓虹灯图形叠加][1]
|
||||
|
||||
JavaScript 的卑微起步始于 1995 年,是由当时在 Netscape 通信公司工作的 Brendan Eich [在短短 10 天内创建的][2]。从那时起,JavaScript 已经走过了漫长的道路,从一个让网站变得漂亮的工具变成了一种严肃的编程语言。
|
||||
|
||||
在其早期,JavaScript 被认为是一种视觉工具,它使网站变得更有趣和更有吸引力。像 [Jakarta Server Pages][3](即 JSP,以前称作 JavaServer Pages)这样的语言曾经用来完成渲染网页的繁重工作,而 JavaScript 则被用来创建基本的交互、视觉增强和动画。
|
||||
|
||||
长期以来,HTML、CSS 和 JavaScript 之间的分界并不明确。前端开发主要由 HTML、CSS 和 JavaScript 组成,形成了标准 Web 技术的“[多层蛋糕][4]”。
|
||||
|
||||
![标准 Web 技术的多层蛋糕][5]
|
||||
|
||||
*标准网络技术的“[多层蛋糕][4]”(Mozilla 开发者网络,[CC BY-SA 4.0][6])*
|
||||
|
||||
HTML 和 CSS 为内容提供结构、格式和样式。一旦网页要做一些超越了显示静态内容的事情,就是 JavaScript 的用武之地。Ecma 国际部开发了 JavaScript 规范,<ruby>万维网联盟<rt>World Wide Web Consortium</rt></ruby>(W3C)开发了 HTML 和 CSS 规范。
|
||||
|
||||
### JavaScript 是如何获得突出地位的
|
||||
|
||||
JavaScript 是如何成为[最受欢迎的][8]编程语言的,背后有一段漫长的[历史][7]。早在 20 世纪 90 年代,Java 是王者,不可避免的人们会与它进行比较。许多工程师认为 JavaScript 不是一门好的编程语言,因为它缺乏对面向对象编程的支持。尽管当时并不明显,但其实 JavaScript 的对象模型和功能特性在其第一个版本中就已经出现了。
|
||||
|
||||
1995 年 JavaScript 匆匆发布后,网景公司将其提交给了<ruby>欧洲计算机制造商协会<rt>European Computer Manufacturers Association</rt></ruby>(ECMA)国际部进行标准化。由此产生了 [ECMAScript][9],这是一个 JavaScript 标准,旨在确保不同 Web 浏览器之间网页的互操作性。ECMAScript 1 于 1997 年 6 月问世,帮助推进了 JavaScript 的标准化。
|
||||
|
||||
在此期间,PHP 和 JSP 成为了服务器端编程语言的流行选择。JSP 作为<ruby>通用网关接口<rt>Common Gateway Interface</rt></ruby>([CGI][10])的首选替代方案获得了突出的地位,因为它可以在 HTML 中嵌入 Java 代码。虽然它很受欢迎,但开发人员发现将 Java 嵌入 HTML 中是不自然的。此外,即使是 HTML 上最简单的文本变化,JSP 也必须经历一个耗时的生命周期。在今天的微服务世界里,面向 JSP 的页面被认为是技术债务。
|
||||
|
||||
[PHP][11] 的工作原理与 JSP 类似,但 PHP 代码以一个通用网关接口([CGI][10])的可执行文件来处理。基于 PHP 的 Web 应用比基于 JSP 的应用更容易部署。总的来说,使用 PHP 更容易上手和运行。今天,PHP 和 JavaScript 是创建动态网站最流行的组合之一:PHP 作为服务器端脚本,JavaScript 作为客户端脚本。
|
||||
|
||||
伴随着 2006 年 [jQuery][12] 的发布,JavaScript 的应用越来越多。jQuery 是一个多用途的 JavaScript 库,简化了繁琐的<ruby>文档对象模型<rt>Document Object Model</rt></ruby>(DOM)管理、事件处理和 [Ajax][13]。
|
||||
|
||||
2009 年 [Node.js][14] 的发布是 JavaScript 发展的转折点。开发者现在可以用 JavaScript 编写服务器端脚本了。紧随其后的是 2010 年发布的 [Backbone.js][15] 和 [AngularJS][16] 等框架。这导致了出现了使用单一语言进行全栈开发的概念。
|
||||
|
||||
2015 年,Ecma 国际部发布了 ECMAScript 6(ES6),它为编写复杂的应用程序增加了包括类声明在内的重要新语法。其他新特性还包括迭代器、箭头函数表达式、`let` 和 `const` 关键字、类型化数组、新的集合(映射、集合和 WeakMap)、Promise、字符串的模板字元以及许多其它很酷的特性。后来的版本又继续增加了更多的功能,使 JavaScript 更加强大、精简和可靠。
|
||||
|
||||
### 总结
|
||||
|
||||
在过去的 20 年里,JavaScript 有了长足的进步。现在大多数浏览器都在争相满足合规性,因此最新的规范推出得更快。
|
||||
|
||||
根据你的项目需求,有大量稳定的 JavaScript 框架可供选择,包括最流行的 [React][17]、[Angular][18] 和 [Vue.js][19] 等等。在本系列的下一篇文章中,我将深入探讨为什么 JavaScript 如此受欢迎。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/10/history-javascript
|
||||
|
||||
作者:[Nimisha Mukherjee][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/nimisha
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_javascript.jpg?itok=60evKmGl (Javascript code close-up with neon graphic overlay)
|
||||
[2]: https://en.wikipedia.org/wiki/JavaScript
|
||||
[3]: https://en.wikipedia.org/wiki/Jakarta_Server_Pages
|
||||
[4]: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_is_JavaScript
|
||||
[5]: https://opensource.com/sites/default/files/uploads/layercakewebtech.png (Layer cake of standard web technologies)
|
||||
[6]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[7]: https://blog.logrocket.com/history-of-frontend-frameworks/
|
||||
[8]: https://octoverse.github.com/
|
||||
[9]: https://en.wikipedia.org/wiki/ECMAScript
|
||||
[10]: https://en.wikipedia.org/wiki/Common_Gateway_Interface
|
||||
[11]: https://en.wikipedia.org/wiki/PHP#:~:text=PHP%20development%20began%20in%201994,Interpreter%22%20or%20PHP%2FFI.
|
||||
[12]: https://en.wikipedia.org/wiki/JQuery
|
||||
[13]: https://en.wikipedia.org/wiki/Ajax_(programming)
|
||||
[14]: https://en.wikipedia.org/wiki/Node.js
|
||||
[15]: https://en.wikipedia.org/wiki/Backbone.js
|
||||
[16]: https://en.wikipedia.org/wiki/AngularJS
|
||||
[17]: https://reactjs.org/
|
||||
[18]: https://angular.io/
|
||||
[19]: https://vuejs.org/
|
@ -0,0 +1,112 @@
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: "xiao-song-123"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
[#]: subject: "Understand your Python code with this open source visualization tool"
|
||||
[#]: via: "https://opensource.com/article/20/11/python-code-viztracer"
|
||||
[#]: author: "Tian Gao https://opensource.com/users/gaogaotiantian"
|
||||
|
||||
使用开源可视化工具来理解您的 Python 代码
|
||||
======
|
||||
VizTracer 工具可以可视化并跟踪 Python 代码,让您可以更深入地了解其工作原理。
|
||||
![Python programming language logo with question marks][1]
|
||||
|
||||
随之 Python 项目变得越来越大、越复杂,理解起它来就变得充满挑战性。即使是您自己独自编写了整个项目,也不可能完全知道项目是如何工作的。为了能更好的理解您的代码,调试和分析代码变得至关重要。
|
||||
|
||||
[VizTracer][2] 是一个这样的工具,它通过跟踪和可视化 Python 代码的执行过程,来帮助您对代码的理解。无需对源代码进行任何更改,VizTracer 即可记录函数的入口 / 出口,函数参数 / 返回值以及任意变量,然后通过 [Trace-Viewer][3] 使用直观的谷歌前端界面来显示数据。
|
||||
|
||||
下面是一个运行[蒙特卡洛树搜索][4]的例子:
|
||||
|
||||
![Monte Carlo tree search visualization][5]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][6])
|
||||
|
||||
每个函数都在时间线上以堆栈的形式记录和可视化,这样您就可以看到在运行程序时发生了什么。您可以放大查看任意特定点的详细信息:
|
||||
|
||||
![Zooming in on VizTracer visualization][7]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][6])
|
||||
|
||||
VizTracer 还可以自动记录函数参数和返回值。您可以单击功能条目并查看详细信息:
|
||||
|
||||
![Viewing VizTracer details][8]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][6])
|
||||
|
||||
或者您可以创建一个全新的信号,并用它来记录变量。例如,这显示了执行梯度下降时的代价值:
|
||||
|
||||
![VizTracer gradient descent][9]
|
||||
|
||||
(Tian Gao, [CC BY-SA 4.0][6])
|
||||
|
||||
与其他设置复杂的工具相比,VizTracer 使用起来非常简单,并且没有任何依赖关系。您可以从 pip 安装它:
|
||||
|
||||
|
||||
```
|
||||
`pip install viztracer`
|
||||
```
|
||||
|
||||
您也可以通过输入来跟踪你的程序 ( `<your_script.py>` 是您脚本的名称):
|
||||
|
||||
|
||||
```
|
||||
`viztracer <your_script.py>`
|
||||
```
|
||||
|
||||
VizTracer 将在您的工作目录中生成一个 HTML 报告,您可以在 Chrome 浏览器中打开它。
|
||||
|
||||
VizTracer 还提供了其他高级功能,比如过滤器功能,您可以使用它过滤掉不想跟踪的函数,获得更清晰的报告。例如,要仅包含文件中的函数,您需要:
|
||||
|
||||
|
||||
```
|
||||
`viztracer include_files ./ --run <your_script.py>`
|
||||
```
|
||||
|
||||
记录函数参数和返回值:
|
||||
|
||||
|
||||
```
|
||||
`viztracer --log_function_args --log_return_value <your_script.py>`
|
||||
```
|
||||
|
||||
记录与某个正则表达式匹配的任意变量:
|
||||
|
||||
|
||||
```
|
||||
# log variables starts with a
|
||||
viztracer --log_var a.* --run <your_script.py>
|
||||
```
|
||||
|
||||
您可以通过对源代码进行较小的修改来获得其他功能,例如自定义事件来记录数值和对象。
|
||||
|
||||
VizTracer 还包括一个虚拟调试器( vdb ),它可以调试 VizTracer 的日志文件。可以用 vdb 调试您运行中的代码 (与 [pdb][10] 非常相似 ) 以便您了解代码流。有用的是,它还支持时间回溯,因为它知道发生的一切。
|
||||
|
||||
与一些原型不同,VizTracer 使用纯 C 语言实现其核心,这将极大地减少开销,使其达到类似于 [cProfile][11] 的水平。
|
||||
|
||||
VizTracer 是开源的,在 Apache 2.0 许可下发布,支持所有常见的操作系统平台(Linux、macOS和Windows)。你可以在 [GitHub][2] 上了解关于它的更多特性并访问源代码。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/11/python-code-viztracer
|
||||
|
||||
作者:[Tian Gao][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[xiao-song-123](https://github.com/xiao-song-123)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/gaogaotiantian
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python_programming_question.png?itok=cOeJW-8r "Python programming language logo with question marks"
|
||||
[2]: https://github.com/gaogaotiantian/viztracer
|
||||
[3]: http://google.github.io/trace-viewer/
|
||||
[4]: https://en.wikipedia.org/wiki/Monte_Carlo_tree_search
|
||||
[5]: https://opensource.com/sites/default/files/uploads/viztracer_mcts.png "Monte Carlo tree search visualization"
|
||||
[6]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[7]: https://opensource.com/sites/default/files/uploads/viztracer_zoomin.png "Zooming in on VizTracer visualization"
|
||||
[8]: https://opensource.com/sites/default/files/uploads/viztracer_details.png "Viewing VizTracer details"
|
||||
[9]: https://opensource.com/sites/default/files/uploads/viztracer_gradient.png "VizTracer gradient descent"
|
||||
[10]: https://docs.python.org/3/library/pdb.html
|
||||
[11]: https://docs.python.org/2/library/profile.html#module-cProfile
|
Loading…
Reference in New Issue
Block a user