done measure time
This commit is contained in:
parent
815f40af70
commit
ee551ec545
@ -14,7 +14,10 @@ public class CustomRequest {
|
||||
this.orderRepository = orderRepository;
|
||||
}
|
||||
@GetMapping("/custom")
|
||||
public List<Order> performCustomRequest() {
|
||||
return orderRepository.customAction();
|
||||
public Long performCustomRequest() {
|
||||
Long start = System.nanoTime();
|
||||
orderRepository.customAction();
|
||||
Long finish = System.nanoTime();
|
||||
return finish - start;
|
||||
}
|
||||
}
|
||||
|
@ -7,12 +7,13 @@ import org.springframework.data.jpa.repository.Query;
|
||||
import java.util.List;
|
||||
|
||||
public interface OrderRepository extends JpaRepository<Order, Long> {
|
||||
// @Query(value = "SELECT \"ORDER\".ID, \"ORDER\".DATE, \"ORDER\".STATUS, \"CAR\".GOS_NUMBER, \"DRIVER\".NAME as driver_name, \"CLIENT\".NAME as client_name FROM \"order\" " +
|
||||
// "JOIN \"CAR\" ON CAR.ID = \"ORDER\".CAR_ID " +
|
||||
// "JOIN \"DRIVER\" ON \"CAR\".DRIVER_ID = \"DRIVER\".ID " +
|
||||
// "JOIN \"CLIENT\" ON \"CLIENT\".ID = \"ORDER\".CLIENT_ID " +
|
||||
// "WHERE \"ORDER\".DATE > '2000-01-01' AND \"ORDER\".VALUE > 10000 AND \"ORDER\".STATUS like 'delivered' " +
|
||||
// "ORDER BY DATE", nativeQuery = true)
|
||||
@Query(value = "SELECT * FROM \"order\"", nativeQuery = true)
|
||||
List<Order> customAction();
|
||||
@Query(value = "SELECT \"order\".ID, \"order\".DATE, \"order\".STATUS, \"car\".GOS_NUMBER, \"driver\".NAME as driver_name, \"client\".NAME as client_name\n" +
|
||||
"FROM \"order\"\n" +
|
||||
"JOIN CAR ON CAR.ID = \"order\".CAR_ID\n" +
|
||||
"JOIN DRIVER ON CAR.DRIVER_ID = DRIVER.ID\n" +
|
||||
"JOIN CLIENT ON CLIENT.ID = \"order\".CLIENT_ID\n" +
|
||||
"WHERE \"order\".DATE > '2000-01-01' AND \"order\".VALUE > 10000 AND \"order\".STATUS like 'delivered'\n" +
|
||||
"ORDER BY date;", nativeQuery = true)
|
||||
// @Query(value = "SELECT * FROM \"order\"", nativeQuery = true)
|
||||
List<Object> customAction();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
spring.jpa.hibernate.ddl-auto=create
|
||||
spring.datasource.initialization-mode=always
|
||||
spring.datasource.platform=postgres
|
||||
spring.datasource.url=jdbc:postgresql://192.168.43.105:5432/subd
|
||||
spring.datasource.username=yan
|
||||
spring.datasource.password=250303zyzf
|
||||
spring.sql.init.mode=always
|
||||
spring.sql.init.platform=postgres
|
||||
spring.datasource.url=jdbc:postgresql://109.197.199.134:5432/subd
|
||||
spring.datasource.username=postgres
|
||||
spring.datasource.password=250303Zyzf-d-grad
|
||||
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
|
@ -7,7 +7,6 @@
|
||||
<title>Vite App</title>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module" src="/node_modules/jquery/dist/jquery.min.js"></script>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
|
6
SUBD-front/package-lock.json
generated
6
SUBD-front/package-lock.json
generated
@ -11,7 +11,6 @@
|
||||
"axios": "^1.3.6",
|
||||
"bootstrap": "^5.2.3",
|
||||
"email-generator": "^1.0.1",
|
||||
"jquery": "^3.6.4",
|
||||
"vue": "^3.2.47",
|
||||
"vue-router": "^4.1.6"
|
||||
},
|
||||
@ -1411,11 +1410,6 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/jquery": {
|
||||
"version": "3.6.4",
|
||||
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.4.tgz",
|
||||
"integrity": "sha512-v28EW9DWDFpzcD9O5iyJXg3R3+q+mET5JhnjJzQUZMHOv67bpSIHq81GEYpPNZHG+XXHsfSme3nxp/hndKEcsQ=="
|
||||
},
|
||||
"node_modules/js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
|
@ -11,7 +11,6 @@
|
||||
"axios": "^1.3.6",
|
||||
"bootstrap": "^5.2.3",
|
||||
"email-generator": "^1.0.1",
|
||||
"jquery": "^3.6.4",
|
||||
"vue": "^3.2.47",
|
||||
"vue-router": "^4.1.6"
|
||||
},
|
||||
|
@ -1,27 +1,30 @@
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
customRequest() {
|
||||
// let dataUrlPrefix = 'http://localhost:8080/';
|
||||
// const response = axios.get(this.dataUrlPrefix + 'custom');
|
||||
// response.data.map(item => console.log(item));
|
||||
$.ajax({
|
||||
url: "/src/database.php",
|
||||
type: 'get',
|
||||
data: {request: 'fetchall'},
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
document.getElementsByClassName('input-group')[0].innerHTML(response);
|
||||
}
|
||||
let count = document.getElementById('measureCount').value;
|
||||
for (let i = 0; i < count; i++) {
|
||||
const response = axios.get("http://localhost:8080/custom")
|
||||
.then(data => {
|
||||
this.wholeTime += data.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
wholeTime: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control" required id="clientCount" placeholder="Количество клиентов">
|
||||
<input type="text" class="form-control" required id="measureCount" placeholder="Количество повторов">
|
||||
<button class="btn btn-primary" type="button" @click.prevent="customRequest">Сгенерировать</button>
|
||||
</div>
|
||||
<p>{{ this.wholeTime / 1000000 }} ms</p>
|
||||
</template>
|
@ -1,21 +0,0 @@
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
reports: [
|
||||
{ name: 'group-students', label: 'Список студентов' },
|
||||
{ name: 'group-disciplines', label: 'Список дисциплин' }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="list-group">
|
||||
<router-link v-for="report in this.reports"
|
||||
:to="'/reports/' + report.name" class="list-group-item list-group-item-action">
|
||||
{{ report.label }}
|
||||
</router-link>
|
||||
</div>
|
||||
</template>
|
@ -1,79 +0,0 @@
|
||||
<p>
|
||||
<?php
|
||||
|
||||
$host = "192.168.43.105";
|
||||
$user = "yan";
|
||||
$password = "250303zyzf";
|
||||
$dbname = "subd";
|
||||
$con = pg_connect("host=$host dbname=$dbname user=$user password=$password");
|
||||
|
||||
if (!$con) {
|
||||
die('Connection failed.');
|
||||
}
|
||||
|
||||
$request = "";
|
||||
if(isset($_POST['request'])){
|
||||
$request = $_POST['request'];
|
||||
}
|
||||
|
||||
// Fetch all records
|
||||
if($request == 'fetchall'){
|
||||
|
||||
$query = "SELECT "order".ID, "order".DATE, "order".STATUS, "car".GOS_NUMBER, "driver".NAME as driver_name, "client".NAME as client_name FROM "order" JOIN CAR ON CAR.ID = "order".CAR_ID JOIN DRIVER ON CAR.DRIVER_ID = DRIVER.ID JOIN CLIENT ON CLIENT.ID = "order".CLIENT_ID WHERE "order".DATE > '2000-01-01' AND "order".VALUE > 10000 AND "order".STATUS like 'delivered' ORDER BY date;";
|
||||
|
||||
$result = pg_query($con, $query);
|
||||
|
||||
$response = array();
|
||||
|
||||
while ($row = pg_fetch_assoc($result) ){
|
||||
|
||||
$id = $row['id'];
|
||||
$username = $row['username'];
|
||||
$fullname = $row['fullname'];
|
||||
$email = $row['email'];
|
||||
|
||||
$response[] = array(
|
||||
"id" => $id,
|
||||
"username" => $username,
|
||||
"fullname" => $fullname,
|
||||
"email" => $email,
|
||||
);
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
die;
|
||||
}
|
||||
|
||||
// Fetch record by id
|
||||
if($request == 'fetchbyid'){
|
||||
|
||||
$userid = 0;
|
||||
if(isset($_POST['userid']) && is_numeric($_POST['userid']) ){
|
||||
$userid = $_POST['userid'];
|
||||
}
|
||||
|
||||
$query = "SELECT * FROM users WHERE id=".$userid;
|
||||
$result = pg_query($con, $query);
|
||||
|
||||
$response = array();
|
||||
if (pg_numrows($result) > 0) {
|
||||
|
||||
$row = pg_fetch_assoc($result);
|
||||
|
||||
$id = $row['id'];
|
||||
$username = $row['username'];
|
||||
$fullname = $row['fullname'];
|
||||
$email = $row['email'];
|
||||
|
||||
$response[] = array(
|
||||
"id" => $id,
|
||||
"username" => $username,
|
||||
"fullname" => $fullname,
|
||||
"email" => $email,
|
||||
);
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
die;
|
||||
}
|
||||
</p>
|
Loading…
Reference in New Issue
Block a user