mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-05 14:31:22 +08:00
bugfix: uniform response time unit to miliseconds
This commit is contained in:
@@ -103,8 +103,8 @@ class HttpSession(requests.Session):
|
|||||||
self.meta_data["request_time"] = time.time()
|
self.meta_data["request_time"] = time.time()
|
||||||
response = self._send_request_safe_mode(method, url, **kwargs)
|
response = self._send_request_safe_mode(method, url, **kwargs)
|
||||||
# record the consumed time
|
# record the consumed time
|
||||||
self.meta_data["response_time"] = int((time.time() - self.meta_data["request_time"]) * 1000)
|
self.meta_data["response_time(ms)"] = round((time.time() - self.meta_data["request_time"]) * 1000, 2)
|
||||||
self.meta_data["elapsed"] = response.elapsed.total_seconds()
|
self.meta_data["elapsed(ms)"] = response.elapsed.microseconds / 1000.0
|
||||||
|
|
||||||
self.meta_data["url"] = (response.history and response.history[0] or response)\
|
self.meta_data["url"] = (response.history and response.history[0] or response)\
|
||||||
.request.path_url
|
.request.path_url
|
||||||
@@ -138,9 +138,9 @@ class HttpSession(requests.Session):
|
|||||||
logger.log_error(u"{exception}".format(exception=str(e)))
|
logger.log_error(u"{exception}".format(exception=str(e)))
|
||||||
else:
|
else:
|
||||||
logger.log_info(
|
logger.log_info(
|
||||||
"""status_code: {}, response_time: {} ms, response_length: {} bytes""".format(
|
"""status_code: {}, response_time(ms): {} ms, response_length: {} bytes""".format(
|
||||||
self.meta_data["status_code"],
|
self.meta_data["status_code"],
|
||||||
self.meta_data["response_time"],
|
self.meta_data["response_time(ms)"],
|
||||||
self.meta_data["content_size"]
|
self.meta_data["content_size"]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ def make_json_serializable(raw_json):
|
|||||||
|
|
||||||
keyorder = ["url", "method", "request_headers", "request_body", "request_time",
|
keyorder = ["url", "method", "request_headers", "request_body", "request_time",
|
||||||
"status_code", "response_headers", "response_body",
|
"status_code", "response_headers", "response_body",
|
||||||
"content_size", "response_time", "elapsed"]
|
"content_size", "response_time(ms)", "elapsed(ms)"]
|
||||||
serializable_ordered_json = OrderedDict(
|
serializable_ordered_json = OrderedDict(
|
||||||
sorted(serializable_json.items(), key=lambda x:keyorder.index(x[0])))
|
sorted(serializable_json.items(), key=lambda x:keyorder.index(x[0])))
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ class HtmlTestResult(unittest.TextTestResult):
|
|||||||
self.records.append({
|
self.records.append({
|
||||||
'name': test.shortDescription(),
|
'name': test.shortDescription(),
|
||||||
'status': status,
|
'status': status,
|
||||||
'response_time': test.meta_data.get("response_time", 0),
|
'response_time_ms': test.meta_data.get("response_time(ms)", 0),
|
||||||
'attachment': attachment,
|
'attachment': attachment,
|
||||||
"meta_data": make_json_serializable(test.meta_data)
|
"meta_data": make_json_serializable(test.meta_data)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -180,7 +180,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th class="{{record.status}}" style="width:5em;">{{record.status}}</td>
|
<th class="{{record.status}}" style="width:5em;">{{record.status}}</td>
|
||||||
<td>{{record.name}}</td>
|
<td>{{record.name}}</td>
|
||||||
<td style="text-align:center;width:6em;">{{ '%0.1f'| format(record.response_time|float) }} ms</td>
|
<td style="text-align:center;width:6em;">{{ '%0.1f'| format(record.response_time_ms|float) }} ms</td>
|
||||||
<td class="detail">
|
<td class="detail">
|
||||||
|
|
||||||
<a class="button" href="#popup_log_{{loop.index}}">log</a>
|
<a class="button" href="#popup_log_{{loop.index}}">log</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user