温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Digest中计算编辑距离以及前端性能测试工具的示例分析

发布时间:2021-09-18 09:41:44 来源:亿速云 阅读:130 作者:柒染 栏目:编程语言

这期内容当中小编将会给大家带来有关Digest中计算编辑距离以及前端性能测试工具的示例分析,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

每天学点算法

谷歌面试题:计算编辑距离

两个字符串的编辑距离是指需要转化为另一个字符串所需要的最少插入、删除和置换的次数。比如 “kitten” 和 “sitting” 的编辑距离是3。

The edit distance between two strings refers to the minimum number of character insertions, deletions, and substitutions required to change one string to the other. For example, the edit distance between “kitten” and “sitting” is three: substitute the “k” for “s”, substitute the “e” for “i”, and append a “g”.

给定两个字符串,计算它们的编辑距离。

Given two strings, compute the edit distance between them.

def edit_distance(string1, string2):
    """Ref: https://bit.ly/2Pf4a6Z"""

    if len(string1) > len(string2):
        difference = len(string1) - len(string2)
        string1[:difference]

    elif len(string2) > len(string1):
        difference = len(string2) - len(string1)
        string2[:difference]

    else:
        difference = 0

    for i in range(len(string1)):
        if string1[i] != string2[i]:
            difference += 1

    return difference

print(edit_distance("kitten", "sitting")) #3
print(edit_distance("medium", "median")) #2

其他值得阅读

这将使你成为一个命令行忍者

原文:This Will Make You a Command-Line Ninja

Unix哲学

Write programs that do one thing and do it well. | 编写的程序只做一件事,而且要做得很好。 Write programs to work together. | 编写的程序要能协同工作。 Write programs to handle text streams, because that is a universal interface. | 编写处理文本流的程序,因为那是一个通用接口。

变量
  • $0 - 当前脚本的名称,

  • $1 .. $9 - 脚本的前9个参数。

  • $# - 传递给脚本的参数数。

  • $@ - 提供给脚本的所有参数。

  • $USER - 运行脚本的用户的用户名。

  • $HOSTNAME - 运行脚本的机器的主机名。

  • $SECONDS - 脚本启动后的秒数。

  • $RANDOM - 每次引用时返回一个不同的随机数。

  • $LINENO - 返回Bash脚本中的当前行号。

如何监控Linux中的基本系统指标

原文:LFCA: How to Monitor Basic System Metrics in Linux

# get the system’s date and the time the system was turned on.
uptime -s
uptime -p

# To get a glimpse of the total and available memory and swap space on your system
free -h

# provides a summary of the real-time system metrics and displays the currently running processes that are managed by the Linux kernel.
top
# $ sudo apt install htop  [On Debian-based]
# $ sudo dnf install htop  [On RHEL-based]
htop

# The df command provides information on hard disk utilization per filesystem.
df -Th
免费的前端性能测试工具

FREE FRONT END PERFORMANCE TESTING TOOLS

  • Web Page Test 可以快速测试加载缓慢的网站是什么问题。

  • GTMetrix 类似于上面, 可以Google PageSpeed Grade和Yslow Grades。

  • Google Page Speed Insights 他们同时提供移动和桌面测试。有趣的是,它们默认使用移动端视图。

  • Y-SLOW Y-slow是一款测试网页速度的浏览器插件(由雅虎推出),除IE外,几乎所有现代浏览器都可以使用。

  • Neustar Ultratools A collection of tools for hosting speed checks, DNS checks, and more. They keep moving things around and adding/removing features.

  • Sitespeed.io 用于评估真实浏览器的客户端性能。

  • ManageWP 可以从一个位置管理多个WP网站。

To be mature you have to realize what you value most. 要想成为一个成熟的人,就必须认识到自己最宝贵的东西。

成功的前提是学会取舍

上述就是小编为大家分享的Digest中计算编辑距离以及前端性能测试工具的示例分析了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI