added onother measurement
This commit is contained in:
parent
ee551ec545
commit
410cacaf6d
@ -5,6 +5,9 @@ import com.subd.subd.Repositories.OrderRepository;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@ -14,9 +17,11 @@ public class CustomRequest {
|
|||||||
this.orderRepository = orderRepository;
|
this.orderRepository = orderRepository;
|
||||||
}
|
}
|
||||||
@GetMapping("/custom")
|
@GetMapping("/custom")
|
||||||
public Long performCustomRequest() {
|
public Long performCustomRequest(String date, Double value, String status, String orderBy) throws ParseException {
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-M-d");
|
||||||
|
Date date1 = format.parse(date);
|
||||||
Long start = System.nanoTime();
|
Long start = System.nanoTime();
|
||||||
orderRepository.customAction();
|
orderRepository.customAction(date1, value, status, orderBy);
|
||||||
Long finish = System.nanoTime();
|
Long finish = System.nanoTime();
|
||||||
return finish - start;
|
return finish - start;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,9 @@ package com.subd.subd.Repositories;
|
|||||||
import com.subd.subd.Models.Order;
|
import com.subd.subd.Models.Order;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface OrderRepository extends JpaRepository<Order, Long> {
|
public interface OrderRepository extends JpaRepository<Order, Long> {
|
||||||
@ -12,8 +14,10 @@ public interface OrderRepository extends JpaRepository<Order, Long> {
|
|||||||
"JOIN CAR ON CAR.ID = \"order\".CAR_ID\n" +
|
"JOIN CAR ON CAR.ID = \"order\".CAR_ID\n" +
|
||||||
"JOIN DRIVER ON CAR.DRIVER_ID = DRIVER.ID\n" +
|
"JOIN DRIVER ON CAR.DRIVER_ID = DRIVER.ID\n" +
|
||||||
"JOIN CLIENT ON CLIENT.ID = \"order\".CLIENT_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" +
|
"WHERE \"order\".DATE > :date AND \"order\".VALUE > :value AND \"order\".STATUS like :status\n" +
|
||||||
"ORDER BY date;", nativeQuery = true)
|
"ORDER BY :orderBy", nativeQuery = true)
|
||||||
// @Query(value = "SELECT * FROM \"order\"", nativeQuery = true)
|
List<Object> customAction(@Param("date") Date date,
|
||||||
List<Object> customAction();
|
@Param("value") Double value,
|
||||||
|
@Param("status") String status,
|
||||||
|
@Param("orderBy") String orderBy);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
spring.jpa.hibernate.ddl-auto=create
|
spring.jpa.hibernate.ddl-auto=create
|
||||||
spring.sql.init.mode=always
|
spring.sql.init.mode=always
|
||||||
spring.sql.init.platform=postgres
|
spring.sql.init.platform=postgres
|
||||||
spring.datasource.url=jdbc:postgresql://109.197.199.134:5432/subd
|
spring.datasource.url=jdbc:postgresql://192.168.31.77:5432/yan
|
||||||
spring.datasource.username=postgres
|
spring.datasource.username=yan
|
||||||
spring.datasource.password=250303Zyzf-d-grad
|
spring.datasource.password=250303zyzf
|
||||||
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
|
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
|
@ -3,10 +3,60 @@
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
customRequest() {
|
generateDate() {
|
||||||
|
let date = new Date((Math.floor(Math.random() * (2023-1950)) + 1950) + '-' + (Math.floor(Math.random() * (12-1)) + 1) + '-' + (Math.floor(Math.random() * (31-1)) + 1));
|
||||||
|
let result = date.getFullYear() + '-';
|
||||||
|
if (date.getMonth().toString().length == 1) {
|
||||||
|
result += '0' + date.getMonth() + '-';
|
||||||
|
} else {
|
||||||
|
result += date.getMonth() + '-';
|
||||||
|
}
|
||||||
|
if (date.getDate().toString().length == 1) {
|
||||||
|
result += '0' + date.getDate();
|
||||||
|
} else {
|
||||||
|
result += date.getDate();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
generateStatus() {
|
||||||
|
let status = [
|
||||||
|
'accepted',
|
||||||
|
'inDelivery',
|
||||||
|
'delivered',
|
||||||
|
'issued'
|
||||||
|
];
|
||||||
|
return status[Math.floor(Math.random() * status.length)];
|
||||||
|
},
|
||||||
|
generateOrderBy() {
|
||||||
|
let orders = [
|
||||||
|
'id',
|
||||||
|
'date',
|
||||||
|
'status',
|
||||||
|
'gos_number',
|
||||||
|
'driver_name',
|
||||||
|
'client_name',
|
||||||
|
];
|
||||||
|
return orders[Math.floor(Math.random() * orders.length)];
|
||||||
|
},
|
||||||
|
customRequestSame() {
|
||||||
let count = document.getElementById('measureCount').value;
|
let count = document.getElementById('measureCount').value;
|
||||||
|
this.wholeTime = 0;
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
const response = axios.get("http://localhost:8080/custom")
|
const response = axios.get("http://localhost:8080/custom?date=2023-2-1&value=1000&status=delivered&orderBy=date")
|
||||||
|
.then(data => {
|
||||||
|
this.wholeTime += data.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
customRequestDif() {
|
||||||
|
let count = document.getElementById('measureCount').value;
|
||||||
|
this.wholeTime = 0;
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
var date = this.generateDate()
|
||||||
|
var value = Math.floor(Math.random() * 1000000);
|
||||||
|
var status = this.generateStatus();
|
||||||
|
var orderBy = this.generateOrderBy();
|
||||||
|
const response = axios.get("http://localhost:8080/custom?date=" + date + "&value=" + value + "&status=" + status + "&orderBy=" + orderBy)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
this.wholeTime += data.data;
|
this.wholeTime += data.data;
|
||||||
});
|
});
|
||||||
@ -24,7 +74,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
<input type="text" class="form-control" required id="measureCount" placeholder="Количество повторов">
|
<input type="text" class="form-control" required id="measureCount" placeholder="Количество повторов">
|
||||||
<button class="btn btn-primary" type="button" @click.prevent="customRequest">Сгенерировать</button>
|
<button class="btn btn-primary" type="button" @click.prevent="customRequestSame">Одинаковые</button>
|
||||||
|
<button class="btn btn-primary" type="button" @click.prevent="customRequestDif">С разными Данными</button>
|
||||||
</div>
|
</div>
|
||||||
<p>{{ this.wholeTime / 1000000 }} ms</p>
|
<p>{{ this.wholeTime / 1000000 }} ms</p>
|
||||||
</template>
|
</template>
|
Loading…
Reference in New Issue
Block a user