File tree 3 files changed +16
-28
lines changed
3 files changed +16
-28
lines changed Original file line number Diff line number Diff line change 1
1
'use server' ;
2
2
3
- import { eq , sql } from 'drizzle-orm' ;
3
+ import { count , eq , sql } from 'drizzle-orm' ;
4
4
import chunk from 'lodash.chunk' ;
5
5
import { comments } from '@/models/schema' ;
6
6
import { db } from '@/utils/db' ;
@@ -84,24 +84,12 @@ async function measureReads(newRecords: number[]) {
84
84
return { reads, readsPerSecond } ;
85
85
}
86
86
87
- /**
88
- * Deletes all comments from the database.
89
- * @returns The time taken to delete the records in milliseconds.
90
- */
91
- async function deleteComments ( ) {
92
- const deleteStart = Date . now ( ) ;
93
- await db . delete ( comments ) . execute ( ) ;
94
- const deleteTime = Date . now ( ) - deleteStart ;
95
-
96
- return deleteTime ;
97
- }
98
-
99
87
type TestResult = {
100
- deleteTime : number ;
101
88
error ?: string ;
102
89
failureRate : number ;
103
90
reads : number ;
104
91
readsPerSecond : number ;
92
+ total : number ;
105
93
writes : number ;
106
94
writesPerSecond : number ;
107
95
writeTime : number ;
@@ -125,13 +113,17 @@ async function runTests(): Promise<TestResult | undefined> {
125
113
const failureRate = Math . round ( ( failures / writes ) * 100 ) ;
126
114
127
115
const { reads, readsPerSecond } = await measureReads ( newRecords ) ;
128
- const deleteTime = await deleteComments ( ) ;
116
+
117
+ const [ { count : total } ] = await db
118
+ . select ( { count : count ( ) } )
119
+ . from ( comments )
120
+ . execute ( ) ;
129
121
130
122
return {
131
- deleteTime,
132
123
failureRate,
133
124
reads,
134
125
readsPerSecond,
126
+ total,
135
127
writes,
136
128
writesPerSecond,
137
129
writeTime,
Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ export default function Home() {
44
44
< div className = "flex flex-col gap-6 sm:flex-row sm:gap-10" >
45
45
< DbTest />
46
46
< Capacity />
47
- < Images />
48
47
</ div >
49
48
</ main >
50
49
) ;
Original file line number Diff line number Diff line change @@ -82,24 +82,21 @@ const DbTest = () => {
82
82
) }
83
83
{ ! loading && result && (
84
84
< ul >
85
- < li className = "font-bold text-foreground" >
85
+ < li >
86
+ Table size: { result . total . toLocaleString ( ) } { ' ' }
87
+ records
88
+ </ li >
89
+ < li >
86
90
Reads/sec:{ ' ' }
87
91
{ result . readsPerSecond . toLocaleString ( ) }
88
92
</ li >
89
- < li > Writes: { result . writes . toLocaleString ( ) } </ li >
90
93
< li >
91
- Write time: { result . writeTime . toLocaleString ( ) }
92
- ms
93
- </ li >
94
- < li className = "font-bold text-foreground" >
95
94
Writes/sec:{ ' ' }
96
95
{ result . writesPerSecond . toLocaleString ( ) }
97
96
</ li >
98
- < li > Failure rate: { result . failureRate } %</ li >
99
- < li >
100
- Cleanup time:{ ' ' }
101
- { result . deleteTime . toLocaleString ( ) } ms
102
- </ li >
97
+ { result . failureRate > 0 && (
98
+ < li > Failure rate: { result . failureRate } %</ li >
99
+ ) }
103
100
</ ul >
104
101
) }
105
102
{ error && (
You can’t perform that action at this time.
0 commit comments