-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f77c5e8
commit 52be745
Showing
8 changed files
with
131 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from datetime import datetime | ||
|
||
from reactpy import component, hooks, html | ||
|
||
|
||
@component | ||
def renders_per_second(): | ||
start_time, _ = hooks.use_state(datetime.now()) | ||
count, set_count = hooks.use_state(0) | ||
seconds_elapsed = (datetime.now() - start_time).total_seconds() | ||
|
||
@hooks.use_effect | ||
def run_tests(): | ||
set_count(count + 1) | ||
|
||
return html.div( | ||
{"id": "test-runner"}, | ||
html.div(f"Total renders: {count}"), | ||
html.div( | ||
{"class_name": "rps"}, | ||
f"Renders Per Second: {count / (seconds_elapsed or 0.01)}", | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.urls import path | ||
|
||
from .views import renders_per_second | ||
|
||
urlpatterns = [ | ||
path("rps/", renders_per_second), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.shortcuts import render | ||
|
||
|
||
def renders_per_second(request): | ||
return render(request, "renders_per_second.html", {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{% load static %} {% load reactpy %} | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="shortcut icon" type="image/png" href="{% static 'favicon.ico' %}" /> | ||
<title>ReactPy</title> | ||
<style> | ||
iframe { | ||
width: 100%; | ||
height: 45px; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<h1>ReactPy Renders Per Second Test Page</h1> | ||
<hr> | ||
{% component "test_app.performance.components.renders_per_second" %} | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters