我正在尝试 wlan1通过 python 代码计算接口上的总网络流量。到目前为止,我尝试过ethtool,,,iftop但大多数这些工具都显示ncurses界面(基于文本的UI)ifstat。nethogs
我尝试过这样的事情
import subprocess
nw_usage = subprocess.Popen(['ifstat', '-i', 'wlan1'])
Run Code Online (Sandbox Code Playgroud)
但它没有给我网络使用值。
我无法弄清楚如何从 ncurses 接口获取单个变量中的网络使用值。(我感觉会有更好的方法来计算网络使用情况)
任何帮助或指导都将是一个很大的帮助。
谢谢
python linux network-programming performance-testing ubuntu-12.04
我的performance testing使用jmeter工具中有以下场景。
Number of Thread users = 100
Ramp-up period (seconds) = 100
Loop count = 10
Run Code Online (Sandbox Code Playgroud)
Ramp-Up period 指示JMeter在开始下一个用户之前延迟多长时间。例如,在我的场景中,我有100 users一个100 secondRamp-Up period,那么启动用户之间的延迟将为1 秒(100 个用户/100 秒)
在 HTTP 请求默认值控制面板中,输入要测试的网站名称 ( http://www.google.com )
参考图片:
有关更多详细信息,请参阅下面的结果图:
在尝试查找字符串中一堆字符的频率时,为什么对 4 个不同的字符运行 string.count(character) 4 次会比使用 collections.Counter(string) 产生更快的执行时间(使用 time.time()) )?
背景:给定由字符串表示的一系列动作。有效移动为 R(右)、L(左)、U(上)和 D(下)。如果移动顺序带我回到原点,则返回 True。否则,返回 false。
# approach - 1 : iterate 4 times (3.9*10^-6 seconds)
def foo1(moves):
return moves.count('U') == moves.count('D') and moves.count('L') == moves.count('R')
# approach - 2 iterate once (3.9*10^-5 seconds)
def foo2(moves):
from collections import Counter
d = Counter(moves)
return d['R'] == d['L'] and d['U'] == d['D']
import time
start = time.time()
moves = "LDRRLRUULRLRLRLRLRLRLRLRLRLRL"
foo1(moves)
# foo2(moves)
end = time.time()
print("--- %s seconds ---" % (end …Run Code Online (Sandbox Code Playgroud) counter performancecounter count performance-testing python-3.x
我正在尝试使用参数对方法进行基准测试。
[Benchmark]
public void ViewPlan(int x)
{
//code here
}
Run Code Online (Sandbox Code Playgroud)
在使用 [Benchmark] 注释执行代码时,出现错误“基准方法 ViewPlan 的签名不正确。方法不应有任何参数”。所以我也尝试向该方法添加 [Arguments] 注释。参考链接: https: //benchmarkdotnet.org/articles/samples/IntroArguments.html
[Benchmark]
[Arguments]
public void ViewPlan(int x)
{
//code here
}
Run Code Online (Sandbox Code Playgroud)
在此 [Arguments] 中,我们还需要指定方法的参数值。但是,x 的值是在调用该功能时动态设置的。有没有办法在 [Arguments] 中动态传递参数值?我们还可以对静态方法进行基准测试吗?如果可以,那么如何进行基准测试?
Mirth Connect 是一款设计用于处理消息流的软件,它具有内置支持,特别是处理 HL7 消息,因此该软件广泛用于医疗保健应用程序中的接口。多年来,我发现 Mirth 软件遇到性能问题,主要是由于消息随着时间的推移而累积,以及在快速连续接收大量消息负载的情况下造成的。
Mirth 具有基于通道的架构,如果我们能够通过某种方式测试 Mirth 通道的性能并获取其性能的 JMeter 统计数据,那就太理想了。由此,我们可以收集必要的信息来优化通道变压器并相应地设置净化例程。
然而,互联网上几乎没有关于这方面的信息,即如何使用 JMeter 测试 Mirth 通道。斯里兰卡的一个团队早在 2013 年就在这个领域做了一些研究,我在下面找到了他们的发现和成就: http://pragmatictestlabs.com/2016/10/09/performance-testing-healthcare-application-hl7-jmeter/
然而,这是非常具体的,这里的输出是他们提取的 JSon 对象,但是在 Mirth 中我们可以有各种形式的输出,并且需要有更好的方法来做到这一点。一个重要的收获是输入,即输入是通用的,我们可以使用 JMeter 生成 HL7 消息并将它们传递给 Mirth,这很棒,但是如何捕获一般响应,如果有一种方法可以读取 Mirth,那就太理想了通过 JMeter 的仪表板,所有输出统计信息都在那里,只需读取它们即可。
我有一个应用程序,Mirth 读取 ADT 和 RDE 的 HL7 消息,并相应地创建一个具有适当内容的文本文件,并将其放置到共享位置。然后应用程序读取文件并向用户显示信息。
我想在这里做两个性能测试
我可以执行第一个操作,因为我可以使用 JMeter 生成 HL7 消息,并且可以让 JMeter 读取应用程序或数据库中的输出。问题在于第二个,我可以用一般的方式来做到这一点吗?
我有 locustio 文档中的下一个代码:
from locust import HttpLocust, TaskSet, between
def login(l):
l.client.post("/login", {"username":"ellen_key", "password":"education"})
def logout(l):
l.client.post("/logout", {"username":"ellen_key", "password":"education"})
def index(l):
l.client.get("/")
def profile(l):
l.client.get("/profile")
class UserBehavior(TaskSet):
tasks = {index: 2, profile: 1}
def on_start(self):
login(self)
def on_stop(self):
logout(self)
class WebsiteUser(HttpLocust):
task_set = UserBehavior
wait_time = between(5.0, 9.0)
Run Code Online (Sandbox Code Playgroud)
在蝗虫日志和蝗虫网络(localhost:8089)中我看到了接下来的任务
- /login
- /logout
- /
- /profile
Run Code Online (Sandbox Code Playgroud)
但是,如果我需要在一项任务中包含很少的请求并从完整的任务(而不是 1 个请求)中获取度量,该怎么办?
我想看到的是:
- login
- logout
- index
- profile
Run Code Online (Sandbox Code Playgroud)
我想查看任务名称而不是请求 url。在 Jmeter 中,我可以在一个操作中插入几个请求并获取操作时间(而不是请求)。
我想模拟高峰流量,例如:
T0)T+5)T+10)是否可以创建相同数量的用户,但不是每秒执行一次,而是改为每 xx 分钟执行一次?
前段时间,我问了以下问题“如何计算进程 id 的执行指令数(包括子进程)”,@M-Iduoad 好心提供了一个解决方案来pgrep捕获所有子 PID 并将其与 perf stat 中的 -p 一起使用。效果很好!
然而,我遇到的一个问题是多线程应用程序以及当生成新线程时。由于我不是算命先生(太糟糕了!),我不知道tid新生成的线程,因此我无法将它们添加到perf stat-p 或 -t 参数中。
举个例子,假设我有一个多线程 Nodejs 服务器(作为容器部署在 Kubernetes 之上),具有以下内容pstree:
root@node2:/home/m# pstree -p 4037791\nnode(4037791)\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80sh(4037824)\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80node(4037825)\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80{node}(4037826)\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80{node}(4037827)\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80{node}(4037828)\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80{node}(4037829)\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80{node}(4037830)\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80{node}(4037831)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037805)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037806)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037807)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037808)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037809)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037810)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037811)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037812)\n \xe2\x94\x9c\xe2\x94\x80{node}(4037813)\n \xe2\x94\x94\xe2\x94\x80{node}(4037814) \nRun Code Online (Sandbox Code Playgroud)\n当然,我可以使用以下perf stat命令来观察其线程:
perf stat --per-thread -e instructions,cycles,task-clock,cpu-clock,cpu-migrations,context-switches,cache-misses,duration_time -p $(pgrep --ns 4037791 | paste -s -d ",")\nRun Code Online (Sandbox Code Playgroud)\n … 我有一个循环,我正在尝试与 OpenMP 有效地并行化。它涉及累积矢量流的 L2 范数,并进行缩减。这是循环:
struct vec3
{
float data[3] = {};
};
float accumulate_eta_sq_t_mass(const vec3* etas, const float* masses, const std::size_t& n)
{
auto a = 0.0;
#pragma omp parallel for simd safelen(16) reduction(+:a)
for (auto ii = std::size_t{}; ii < n; ++ii)
{
const auto& eta = etas[ii];
const auto x = static_cast<double>(eta.data[0]);
const auto y = static_cast<double>(eta.data[1]);
const auto z = static_cast<double>(eta.data[2]);
const auto m = static_cast<double>(masses[ii]);
a += (x * x + y * y + …Run Code Online (Sandbox Code Playgroud) c++ benchmarking openmp performance-testing parallelism-amdahl
作为我的性能测试的一部分,我需要调试会话等.如果我删除,相同的代码正在运行session =>.当我添加它说它在模拟期间没有发送请求,因为它没有发送任何请求.
val scn1 = scenario("LaunchAction").exec{ session =>
http("Poll report status page report")
.get("myURL/rest/reports")
.queryParam("applicationId", "123")
.queryParam("id", "1")
.check(xpath("//status").saveAs("responseStatus"))
session
}
Run Code Online (Sandbox Code Playgroud)
我需要在它们之间添加一些打印件等.你能提供一些信息吗?
python ×3
jmeter ×2
linux ×2
locust ×2
benchmarking ×1
c# ×1
c++ ×1
count ×1
counter ×1
gatling ×1
load ×1
mirth ×1
openmp ×1
perf ×1
performance ×1
profiling ×1
python-3.x ×1
scala ×1
taurus ×1
ubuntu-12.04 ×1