-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
512 lines (512 loc) · 26.1 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
#limits = c(0, 100)) +
scale_x_continuous(
breaks = seq(0, max(df_list_hw[[df_name]]$seconds), by = 20),
#sprintf() is a function in R that allows you to format strings with placeholders for variables. It takes two arguments: the format string and the variables to substitute into the string. The format string is a character string that includes placeholders for the variables.
labels = function(x) sprintf("%2d:%02d", floor(x/60), x %% 60),
minor_breaks = seq(0, max(df_list_hw[[df_name]]$seconds), by = 10),
) +
scale_color_manual(name = NULL, values = c("CPU Fan" = "red", "GPU Fan" = "blue", "Case" = "green")) +
theme_clean() +
theme(
panel.grid.minor.y = element_line(color = "gray", linetype = "dotted"),
legend.text = element_text(size = 6),
legend.background = element_rect(fill = "grey99", color = "black", size = 0.5)) #makes a box around the legend and adds a fill!
fan_speed_list[[df_name]] <- fan_speed
}
fan_speed_list[[game]]
temp_power_cpu_list <- list()
for (df_name in names(df_list_hw)) {
temp_power_cpu <- ggplot(df_list_hw[[df_name]], aes(seconds)) +
geom_line(aes(y = CPU.Package.Power..W., color = "CPU Power")) +
geom_line(aes(y = CPU..Tctl.Tdie....C., color = "CPU Temp")) +
#Adding the average measure into the graph
annotate("text", x = -Inf, y = Inf,
label = paste0("Avg CPU Power: ", round(mean(df_list_hw[[df_name]]$CPU.Package.Power..W.), 1), " W", "\n",
"Avg CPU Temp: ", round(mean(df_list_hw[[df_name]]$CPU..Tctl.Tdie....C.), 1), " *C", "\n"),
size = 2.5, color = "black", hjust = -0.05, vjust = 1.1) +
labs(
x = "Time (M:SS)",
title = paste0("CPU Power and Temperature Over Time in ", toTitleCase(df_name))
) +
scale_x_continuous(
breaks = seq(0, max(df_list_hw[[df_name]]$seconds), by = 20),
#sprintf() is a function in R that allows you to format strings with placeholders for variables. It takes two arguments: the format string and the variables to substitute into the string. The format string is a character string that includes placeholders for the variables.
labels = function(x) sprintf("%02d:%02d", floor(x/60), x %% 60)
) +
scale_y_continuous(name = "Power Draw (Watts)" ,
sec.axis = sec_axis(~., name = "Temperature (*C)")) +
#breaks = seq(40, 80, by = 5),
#minor_breaks = seq(40, 80, by = 2.5),
#limits = c(40, 80)) +
scale_color_manual(name = NULL,
values = c("CPU Power" = "red", "CPU Temp" = "blue")) +
theme_clean() +
theme(panel.grid.minor.y = element_line(color = "gray", linetype = "dotted"),
legend.position = c(0.85, 0.90),
legend.direction = "horizontal",
legend.text = element_text(size = 6),
legend.background = element_rect(fill = "grey99", color = "black", size = 0.5)) + #makes a box around the legend and adds a fill!
guides(fill = guide_legend(reverse = TRUE))
temp_power_cpu_list[[df_name]] <- temp_power_cpu
rm(temp_power_cpu)
}
temp_power_cpu_list[[game]]
#The "cairo = FALSE" parameter should get rid of the anti aliasing on the cinebench text
#ggsave(filename = "my_plot.png", dpi = 300, cairo = FALSE)
temp_power_gpu_list <- list()
for (df_name in names(df_list_hw)) {
temp_power_gpu <- ggplot(df_list_hw[[df_name]], aes(seconds)) +
geom_line(aes(y = GPU.PPT..W., color = "GPU Power")) +
geom_line(aes(y = GPU.Temperature...C., color = "GPU Temp")) +
#Adding the average measure into the graph
annotate("text", x = -Inf, y = Inf,
label = paste0("Avg GPU Power: ", round(mean(df_list_hw[[df_name]]$GPU.PPT..W.), 1), " W", "\n",
"Avg GPU Temp: ", round(mean(df_list_hw[[df_name]]$GPU.Temperature...C.), 1), " *C","\n"),
size = 2.5, color = "black", hjust = -0.05, vjust = 1.1) +
labs(
x = "Time (M:SS)",
title = paste0("GPU Power and Temperature Over Time in ", toTitleCase(df_name))
) +
scale_x_continuous(
breaks = seq(0, max(df_list_hw[[df_name]]$seconds), by = 20),
#sprintf() is a function in R that allows you to format strings with placeholders for variables. It takes two arguments: the format string and the variables to substitute into the string. The format string is a character string that includes placeholders for the variables.
labels = function(x) sprintf("%02d:%02d", floor(x/60), x %% 60)
) +
scale_y_continuous(name = "Power Draw (Watts)" ,
sec.axis = sec_axis(~., name = "Temperature (*C)")) +
#breaks = seq(40, 80, by = 5),
#minor_breaks = seq(40, 80, by = 2.5),
#limits = c(40, 80)) +
scale_color_manual(name = NULL,
values = c("GPU Power" = "blue", "GPU Temp" = "red")) +
theme_clean() +
theme(panel.grid.minor.y = element_line(color = "gray", linetype = "dotted"),
legend.direction = "horizontal",
legend.position = c(0.85, 0.90),
legend.text = element_text(size = 6),
legend.background = element_rect(fill = "grey99", color = "black", size = 0.5)) + #makes a box around the legend and adds a fill!
guides(fill = guide_legend(reverse = TRUE))
temp_power_gpu_list[[df_name]] <- temp_power_gpu
rm(temp_power_gpu)
}
temp_power_gpu_list[[game]]
dfs_subset[[df_name]]$`CPUClk(MHz)`
View(Frametime_R6)
df_list_hw[[df_name]]$Core.Clocks..avg...MHz.
library(tidyverse)
library(readxl)
library(lubridate) #for date extraction and manipulation
library(ggthemes)
library(tools) #for toTitleCase function (makes strings into propercase)
excel_file_hwinfo = "C:/Users/Ryan/Coding Projects/Computer Benchmark/Data/hwinfo_test.xlsx"
hwinfo_ow <- read_excel(excel_file_hwinfo, sheet = "hwinfo_ow")
hwinfo_destiny <- read_excel(excel_file_hwinfo, sheet = "hwinfo_destiny")
hwinfo_r6 <- read_excel(excel_file_hwinfo, sheet = "hwinfo_r6")
hwinfo_gtav <- read_excel(excel_file_hwinfo, sheet = "hwinfo_gtav")
hwinfo_apex <- read_excel(excel_file_hwinfo, sheet = "hwinfo_apex")
hwinfo_rl <- read_excel(excel_file_hwinfo, sheet = "hwinfo_rl")
hwinfo_battlefront <- read_excel(excel_file_hwinfo, sheet = "hwinfo_battlefront")
hwinfo_halo <- read_excel(excel_file_hwinfo, sheet = "hwinfo_halo")
hwinfo_fortnite <- read_excel(excel_file_hwinfo, sheet = "hwinfo_fortnite")
hwinfo_cod <- read_excel(excel_file_hwinfo, sheet = "hwinfo_cod")
#Creating a list of dataframes from above
df_list_hw <- list(hwinfo_ow, hwinfo_destiny, hwinfo_r6, hwinfo_gtav, hwinfo_apex, hwinfo_rl, hwinfo_battlefront, hwinfo_halo, hwinfo_fortnite, hwinfo_cod)
# Rename each data frame in the list to match its sheet name
names(df_list_hw) <- c("overwatch", "destiny", "r6", "gtav", "apex", "rocket_league", "battlefront", "halo", "fortnite", "cod")
# Remove the last 2 rows from each data frame
df_list_hw <- lapply(df_list_hw, function(df) head(df, -2))
# Convert all columns (except for the date column) to numeric then recombines original date variable to numeric dataset
df_list_hw <- lapply(df_list_hw, function(df) {
df_num <- as.data.frame(lapply(df[-1], as.numeric))
cbind(df[1], df_num)
})
# Rename the date column to "DateTime"
df_list_hw <- lapply(df_list_hw, function(df) {
names(df)[1] <- "DateTime"
df
})
# Convert the "DateTime" column to POSIXct format
df_list_hw <- lapply(df_list_hw, function(df) {
df$DateTime <- ymd_hms(df$DateTime)
df
})
# Add a "seconds" column representing seconds since the first observation
df_list_hw <- lapply(df_list_hw, function(df) {
df$seconds <- as.numeric(df$DateTime - min(df$DateTime))
df
})
excel_file_frameview = "C:/Users/Ryan/Coding Projects/Computer Benchmark/Data/frameview_files.xlsx"
Frameview_GTAV <- read_excel(excel_file_frameview, sheet = "GTA5")
Frametime_ow <- read_excel(excel_file_frameview, sheet = "Overwatch")
Frametime_R6 <- read_excel(excel_file_frameview, sheet = "RainbowSix")
Frameview_Apex <- read_excel(excel_file_frameview, sheet = "r5apex")
Frameview_Destiny <- read_excel(excel_file_frameview, sheet = "destiny2")
Frameview_RL <- read_excel(excel_file_frameview, sheet = "RocketLeague")
Frameview_battlefront <- read_excel(excel_file_frameview, sheet = "starwarsbattlefrontii")
frameview_halo <- read_excel(excel_file_frameview, sheet = "HaloInfinite")
frameview_fortnite <- read_excel(excel_file_frameview, sheet = "FortniteClient")
frameview_cod <- read_excel(excel_file_frameview, sheet = "cod")
#list of dataframes
df_list <- list(Frameview_GTAV, Frametime_ow, Frametime_R6, Frameview_Apex, Frameview_Destiny, Frameview_RL, Frameview_battlefront, frameview_halo, frameview_fortnite, frameview_cod)
names(df_list) <- c("gtav", "overwatch", "r6", "apex", "destiny", "rocket_league", "battlefront", "halo", "fortnite", "cod")
# Define the columns to select
cols_to_select <- c("TimeInSeconds", "MsBetweenPresents", "MsBetweenDisplayChange", "GPU1Clk(MHz)", "GPU1Util(%)", "GPU1Temp(C)", "AMDPwr(W) (API)", "CPUClk(MHz)", "CPUUtil(%)", "CPU Package Temp(C)", "CPU Package Power(W)")
# Apply the select statement to each data frame in the list
dfs_all <- lapply(df_list, function(df) select(df, cols_to_select))
# Add the seconds variable to each data frame in the list
dfs_all <- lapply(dfs_all, function(df) {
df$seconds <- as.numeric(df$TimeInSeconds - min(df$TimeInSeconds))
return(df)
})
#Way to thin out the observations in my dataset, although it makes no difference at large time intervals, once we zoom in on a specific time thinning out the data helps to smooth the time series graph and avoids it being so jagged
#This specific code reports values of variables 3 times a second
dfs_subset <- lapply(dfs_all, function(df) df[seq(1, nrow(df), by = 100), ])
rm(df_list)
#("gtav", "overwatch", "r6", "apex", "destiny", "rocket_league", "battlefront", "halo", "fortnite", "cod")
game <- "fortnite"
frametime_plots <- list()
for (df_name in names(dfs_all)) {
frametime <- ggplot(dfs_all[[df_name]], aes(seconds, MsBetweenPresents)) +
geom_line(color = "blue") +
labs(
y = "Frametime",
x = "Seconds",
title = paste0("Frametimes for ", df_name)
) +
#scale_y_continuous(breaks = seq(0, 20, by = 2),
#limits = c(0, 20)) +
scale_x_continuous(labels = function(x) sprintf("%02d:%02d", floor(x/60), x %% 60)) +
theme_bw()
frametime_plots[[df_name]] <- frametime
}
frametime_plots[[game]]
rm(frametime)
temperautre_plots <- list()
for (df_name in names(dfs_subset)) {
temp <- ggplot(dfs_subset[[df_name]], aes(seconds)) +
geom_line(aes(y = `CPU Package Temp(C)`, color = "CPU")) +
geom_line(aes(y = `GPU1Temp(C)`, color = "GPU")) +
#Adding the average measure into the graph
annotate("text", x = -Inf, y = Inf,
label = paste0("Avg CPU Temp: ", round(mean(dfs_subset[[df_name]]$`CPU Package Temp(C)`), 2), "\n",
"Avg GPU Temp: ", round(mean(dfs_subset[[df_name]]$`GPU1Temp(C)`), 2)),
size = 2.5, color = "black", hjust = -0.05, vjust = 1.1) +
labs(
y = "Temperature (*C)",
x = "Time - Minute:Seconds",
title = paste0("CPU & GPU Temp Over Time in ", toTitleCase(df_name))
) +
scale_x_continuous(
breaks = seq(0, max(dfs_subset[[df_name]]$seconds), by = 10),
#sprintf() is a function in R that allows you to format strings with placeholders for variables. It takes two arguments: the format string and the variables to substitute into the string. The format string is a character string that includes placeholders for the variables.
labels = function(x) sprintf("%02d:%02d", floor(x/60), x %% 60)
) +
scale_y_continuous(breaks = seq(50, 75, by = 5),
#minor_breaks = seq(40, 80, by = 2.5),
limits = c(50, 75)) +
scale_color_manual(name = NULL,
values = c("CPU" = "red", "GPU" = "blue")) +
theme_clean() +
theme(panel.grid.minor.y = element_line(color = "gray", linetype = "dotted"),
legend.direction = "horizontal",
legend.position = c(0.85, 0.88),
legend.text = element_text(size = 6),
legend.background = element_rect(fill = "grey99", color = "black", size = 0.5)) #makes a box around the legend and adds a fill!
temperautre_plots[[df_name]] <- temp
}
temperautre_plots[[game]]
utilization_plots <- list()
for (df_name in names(dfs_subset)) {
utilization <- ggplot(dfs_subset[[df_name]], aes(seconds)) +
geom_line(aes(y = `CPUUtil(%)`, color = "CPU")) +
geom_line(aes(y = `GPU1Util(%)`, color = "GPU")) +
#Adding the average measure into the graph
annotate("text", x = -Inf, y = Inf,
label = paste0("Avg CPU Util: ", round(mean(dfs_subset[[df_name]]$`CPUUtil(%)`), 2), "%", "\n",
"Avg GPU Util: ", round(mean(dfs_subset[[df_name]]$`GPU1Util(%)`), 2), "%"),
size = 2.5, color = "black", hjust = -0.05, vjust = 1.1) +
labs(
y = "Percent Utilized",
x = "Time - (Minute:Seconds)",
title = paste0("CPU & GPU Utilization Over Time in ", toTitleCase(df_name))
) +
scale_y_continuous(labels = scales::percent_format(scale = 1),
breaks = seq(0, 100, by = 20),
limits = c(0, 100)) +
scale_x_continuous(
breaks = seq(0, max(dfs_subset[[df_name]]$seconds), by = 10),
#sprintf() is a function in R that allows you to format strings with placeholders for variables. It takes two arguments: the format string and the variables to substitute into the string. The format string is a character string that includes placeholders for the variables.
labels = function(x) sprintf("%2d:%02d", floor(x/60), x %% 60)
) +
scale_color_manual(name = "", values = c("CPU" = "red", "GPU" = "blue")) +
theme_clean() +
theme(
panel.grid.minor.y = element_line(color = "gray", linetype = "dotted"),
legend.position = c(0.85, 0.90),
legend.direction = "horizontal",
legend.text = element_text(size = 6),
legend.background = element_rect(fill = "grey99", color = "black", size = 0.5)) #makes a box around the legend and adds a fill!
utilization_plots[[df_name]] <- utilization
}
utilization_plots[[game]]
cpu_clk_plots <- list()
for (df_name in names(dfs_subset)) {
CPU_cl <- ggplot(dfs_subset[[df_name]],aes(seconds)) +
geom_line(aes(y = `CPUClk(MHz)`), color = "red") +
labs(
y = "CPU Speed (MHz)",
x = "Time - (Minute:Seconds)",
title = paste0("CPU clock Speed During game Run in ", toTitleCase(df_name))
) +
#Adding the average measure into the graph
annotate("text", x = -Inf, y = Inf,
label = paste0("Avg CPU clk: ", round(mean(dfs_subset[[df_name]]$`CPUClk(MHz)`), 2)),
size = 2.5, color = "black", hjust = -0.05, vjust = 1.1) +
scale_x_continuous(
breaks = seq(0, max(dfs_subset[[df_name]]$seconds), by = 20),
#sprintf() is a function in R that allows you to format strings with placeholders for variables. It takes two arguments: the format string and the variables to substitute into the string. The format string is a character string that includes placeholders for the variables.
labels = function(x) sprintf("%02d:%02d", floor(x/60), x %% 60)
) +
scale_y_continuous(
breaks = seq(3500, 5500, by = 250),
limits = c(3500, 5500),
minor_breaks = seq(3500, 5500, by = 125)) +
#scale_color_manual(name = "Measures",
#value = "Core.Clocks..avg...MHz." = "blue") +
theme_clean() +
theme(panel.grid.minor.y = element_line(color = "gray", linetype = "dotted"),
legend.position = c(0.65, 0.40),
legend.title = element_text(size = 10.5),
legend.text = element_text(size = 10),
legend.background = element_rect(fill = "grey99", color = "black", size = 0.5)) #makes a box around the legend and adds a fill!
cpu_clk_plots[[df_name]] <- CPU_cl
}
cpu_clk_plots[[game]]
gpu_cl_plots <- list()
for (df_name in names(dfs_subset)) {
GPU_cl <- ggplot(dfs_subset[[df_name]], aes(seconds)) +
geom_line(aes(y = `GPU1Clk(MHz)`), color = "red") +
labs(
y = "GPU Clock Speed (MHz)",
x = "Time - (Minute:Seconds)",
title = paste0("GPU clock Speed During game Run in ", toTitleCase(df_name))
) +
#Adding the average measure into the graph
annotate("text", x = -Inf, y = Inf,
label = paste0("Avg GPU clk: ", round(mean(dfs_subset[[df_name]]$`GPU1Clk(MHz)`), 2)),
size = 2.5, color = "black", hjust = -0.05, vjust = 1.1) +
scale_x_continuous(
breaks = seq(0, max(dfs_subset[[df_name]]$seconds), by = 20),
#sprintf() is a function in R that allows you to format strings with placeholders for variables. It takes two arguments: the format string and the variables to substitute into the string. The format string is a character string that includes placeholders for the variables.
labels = function(x) sprintf("%02d:%02d", floor(x/60), x %% 60)
) +
#scale_y_continuous(
#breaks = seq(3500, 5500, by = 250),
#limits = c(3500, 5500),
#minor_breaks = seq(3500, 5500, by = 125)) +
#scale_color_manual(name = "Measures",
#value = "Core.Clocks..avg...MHz." = "blue") +
theme_clean() +
theme(panel.grid.minor.y = element_line(color = "gray", linetype = "dotted"),
legend.position = c(0.65, 0.40),
legend.title = element_text(size = 10.5),
legend.text = element_text(size = 10),
legend.background = element_rect(fill = "grey99", color = "black", size = 0.5)) #makes a box around the legend and adds a fill!
gpu_cl_plots[[df_name]] <- GPU_cl
}
gpu_cl_plots[[game]]
power_plots <- list()
for (df_name in names(df_list_hw)) {
power <- ggplot(df_list_hw[[df_name]], aes(seconds)) +
geom_line(aes(y = CPU.Package.Power..W., color = "CPU")) +
geom_line(aes(y = GPU.PPT..W., color = "GPU")) +
#Adding the average measure into the graph
annotate("text", x = -Inf, y = Inf,
label = paste0("Avg CPU Power: ", round(mean(df_list_hw[[df_name]]$CPU.Package.Power..W.), 1), " W", "\n",
"Avg GPU Power: ", round(mean(df_list_hw[[df_name]]$GPU.PPT..W.), 1), " W"),
size = 2.5, color = "black", hjust = -0.05, vjust = 1.1) +
labs(
y = "Power Draw (Watts)",
x = "Time - (Minute:Seconds)",
title = paste0("CPU & GPU Power Consumption Over Time in ", toTitleCase(df_name))
) +
scale_y_continuous(breaks = seq(0, 300, by = 50),
minor_breaks = seq(0, 300, by = 25),
limits = c(0, 300)) +
scale_x_continuous(
breaks = seq(0, max(df_list_hw[[df_name]]$seconds), by = 20),
#sprintf() is a function in R that allows you to format strings with placeholders for variables. It takes two arguments: the format string and the variables to substitute into the string. The format string is a character string that includes placeholders for the variables.
labels = function(x) sprintf("%2d:%02d", floor(x/60), x %% 60)
) +
scale_color_manual(name = NULL, values = c("CPU" = "red", "GPU" = "blue")) +
theme_clean() +
theme(
panel.grid.minor.y = element_line(color = "gray", linetype = "dotted"),
legend.position = c(0.85, 0.92),
legend.direction = "horizontal",
legend.text = element_text(size = 6),
legend.background = element_rect(fill = "grey99", color = "black", size = 0.5)) #makes a box around the legend and adds a fill!
power_plots[[df_name]] <- power
rm(power)
}
power_plots[[game]]
fan_speed_list <- list()
for (df_name in names(df_list_hw)) {
fan_speed <- ggplot(df_list_hw[[df_name]], aes(seconds)) +
geom_line(aes(y = CPU..RPM., color = "CPU Fan")) +
geom_line(aes(y = GPU.Fan..RPM., color = "GPU Fan")) +
geom_line(aes(y = System.2..RPM., color = "Case")) +
#Adding the average measure into the graph
annotate("text", x = -Inf, y = Inf,
label = paste0("Avg CPU Fan: ", round(mean(df_list_hw[[df_name]]$CPU..RPM.), 1), "\n",
"Avg GPU Fan: ", round(mean(df_list_hw[[df_name]]$GPU.Fan..RPM.), 1),"\n",
"Avg Case Fan: ", round(mean(df_list_hw[[df_name]]$System.2..RPM.), 1),"\n"),
size = 2.5, color = "black", hjust = -0.05, vjust = 1.1) +
labs(
y = "Fan speed (RPM)",
x = "Time - (Minute:Seconds)",
title = paste0("Fan Speed Over Time in ", toTitleCase(df_name))
) +
#scale_y_continuous(breaks = seq(0, 100, by = 20),
#limits = c(0, 100)) +
scale_x_continuous(
breaks = seq(0, max(df_list_hw[[df_name]]$seconds), by = 20),
#sprintf() is a function in R that allows you to format strings with placeholders for variables. It takes two arguments: the format string and the variables to substitute into the string. The format string is a character string that includes placeholders for the variables.
labels = function(x) sprintf("%2d:%02d", floor(x/60), x %% 60),
minor_breaks = seq(0, max(df_list_hw[[df_name]]$seconds), by = 10),
) +
scale_color_manual(name = NULL, values = c("CPU Fan" = "red", "GPU Fan" = "blue", "Case" = "green")) +
theme_clean() +
theme(
panel.grid.minor.y = element_line(color = "gray", linetype = "dotted"),
legend.text = element_text(size = 6),
legend.background = element_rect(fill = "grey99", color = "black", size = 0.5)) #makes a box around the legend and adds a fill!
fan_speed_list[[df_name]] <- fan_speed
}
fan_speed_list[[game]]
temp_power_cpu_list <- list()
for (df_name in names(df_list_hw)) {
temp_power_cpu <- ggplot(df_list_hw[[df_name]], aes(seconds)) +
geom_line(aes(y = CPU.Package.Power..W., color = "CPU Power")) +
geom_line(aes(y = CPU..Tctl.Tdie....C., color = "CPU Temp")) +
#Adding the average measure into the graph
annotate("text", x = -Inf, y = Inf,
label = paste0("Avg CPU Power: ", round(mean(df_list_hw[[df_name]]$CPU.Package.Power..W.), 1), " W", "\n",
"Avg CPU Temp: ", round(mean(df_list_hw[[df_name]]$CPU..Tctl.Tdie....C.), 1), " *C", "\n"),
size = 2.5, color = "black", hjust = -0.05, vjust = 1.1) +
labs(
x = "Time (M:SS)",
title = paste0("CPU Power and Temperature Over Time in ", toTitleCase(df_name))
) +
scale_x_continuous(
breaks = seq(0, max(df_list_hw[[df_name]]$seconds), by = 20),
#sprintf() is a function in R that allows you to format strings with placeholders for variables. It takes two arguments: the format string and the variables to substitute into the string. The format string is a character string that includes placeholders for the variables.
labels = function(x) sprintf("%02d:%02d", floor(x/60), x %% 60)
) +
scale_y_continuous(name = "Power Draw (Watts)" ,
sec.axis = sec_axis(~., name = "Temperature (*C)")) +
#breaks = seq(40, 80, by = 5),
#minor_breaks = seq(40, 80, by = 2.5),
#limits = c(40, 80)) +
scale_color_manual(name = NULL,
values = c("CPU Power" = "red", "CPU Temp" = "blue")) +
theme_clean() +
theme(panel.grid.minor.y = element_line(color = "gray", linetype = "dotted"),
legend.position = c(0.85, 0.90),
legend.direction = "horizontal",
legend.text = element_text(size = 6),
legend.background = element_rect(fill = "grey99", color = "black", size = 0.5)) + #makes a box around the legend and adds a fill!
guides(fill = guide_legend(reverse = TRUE))
temp_power_cpu_list[[df_name]] <- temp_power_cpu
rm(temp_power_cpu)
}
temp_power_cpu_list[[game]]
#The "cairo = FALSE" parameter should get rid of the anti aliasing on the cinebench text
#ggsave(filename = "my_plot.png", dpi = 300, cairo = FALSE)
temp_power_gpu_list <- list()
for (df_name in names(df_list_hw)) {
temp_power_gpu <- ggplot(df_list_hw[[df_name]], aes(seconds)) +
geom_line(aes(y = GPU.PPT..W., color = "GPU Power")) +
geom_line(aes(y = GPU.Temperature...C., color = "GPU Temp")) +
#Adding the average measure into the graph
annotate("text", x = -Inf, y = Inf,
label = paste0("Avg GPU Power: ", round(mean(df_list_hw[[df_name]]$GPU.PPT..W.), 1), " W", "\n",
"Avg GPU Temp: ", round(mean(df_list_hw[[df_name]]$GPU.Temperature...C.), 1), " *C","\n"),
size = 2.5, color = "black", hjust = -0.05, vjust = 1.1) +
labs(
x = "Time (M:SS)",
title = paste0("GPU Power and Temperature Over Time in ", toTitleCase(df_name))
) +
scale_x_continuous(
breaks = seq(0, max(df_list_hw[[df_name]]$seconds), by = 20),
#sprintf() is a function in R that allows you to format strings with placeholders for variables. It takes two arguments: the format string and the variables to substitute into the string. The format string is a character string that includes placeholders for the variables.
labels = function(x) sprintf("%02d:%02d", floor(x/60), x %% 60)
) +
scale_y_continuous(name = "Power Draw (Watts)" ,
sec.axis = sec_axis(~., name = "Temperature (*C)")) +
#breaks = seq(40, 80, by = 5),
#minor_breaks = seq(40, 80, by = 2.5),
#limits = c(40, 80)) +
scale_color_manual(name = NULL,
values = c("GPU Power" = "blue", "GPU Temp" = "red")) +
theme_clean() +
theme(panel.grid.minor.y = element_line(color = "gray", linetype = "dotted"),
legend.direction = "horizontal",
legend.position = c(0.85, 0.90),
legend.text = element_text(size = 6),
legend.background = element_rect(fill = "grey99", color = "black", size = 0.5)) + #makes a box around the legend and adds a fill!
guides(fill = guide_legend(reverse = TRUE))
temp_power_gpu_list[[df_name]] <- temp_power_gpu
rm(temp_power_gpu)
}
temp_power_gpu_list[[game]]
#Data Wrangling
summary_fps <- read_excel(excel_file_frameview, sheet = "Summary")
#contains columns I might find important later but don't rn like `Min FPS`, `Max FPS`
summary_fps_o <- summary_fps %>% select(Application, `Avg FPS`, `1% Low FPS`, `0.1% Low FPS`, `Min FPS`, `Max FPS`)
summary_fps <- summary_fps %>% select(Application, `Avg FPS`, `1% Low FPS`, `0.1% Low FPS`)
#code to strip the .exe from the application variable so that it just displays the game name
pattern <- "\\.exe$"
summary_fps$Application <- str_replace(summary_fps$Application, pattern, "")
#Code to calculate averages of "Avg FPS", "1% Low FPS", and "0.1% Low FPS" across game observations (the goal is 3 observations per game then take the averages of that)
summary_fps <- summary_fps %>% group_by(Application) %>%
summarise('AVG FPS' = mean(`Avg FPS`),
'1% Lows' = mean(`1% Low FPS`),
'0.1% Lows' = mean(`0.1% Low FPS`))
#Pivoting the data to a longer format so that each of my FPS measures has their own column
summary_fps_long <- pivot_longer(summary_fps, cols = c("AVG FPS", "1% Lows", "0.1% Lows"), names_to = "fps_type", values_to = "fps")
#Changing the names of the games in the application column to better fit
summary_fps_long <- summary_fps_long %>%
mutate(Application = recode(Application,
"FortniteClient-Win64-Shipping" = "Fortnite",
"starwarsbattlefrontii" = "SW Battlefront II",
"r5apex" = "Apex",
"cod" = "COD: Warzone",
"destiny2" = "Destiny 2"))
#Original
#hehe <- pivot_longer(summary_fps, cols = c("Avg FPS", "1% Low FPS", "0.1% Low FPS"), names_to = "fps_type", values_to = "fps")
#changing the format of the newly created FPS column so that it only displays out to 1 decimal point string to display all numbers
summary_fps_long$fps <- round(summary_fps_long$fps, digits = 1)
############# NOT AS EASY TO REODER A GROUPED BAR CHART AS IT IS A BOXPLOT #############
#Reordering the dataset to display by descending order in the box plot
#group_ordered <- with(summary_fps_long, reorder(fps, desc('AVG FPS'), mean))
#boxplot_circ_day$branch <- factor(boxplot_circ_day$branch, levels = levels(group_ordered))
# Plot horizontal bar chart for all selected games
fps_bar <- summary_fps_long %>% ggplot(aes(x = fps , y = Application, fill = fps_type)) +
geom_text(aes(label = fps), hjust = -0.1, position = position_dodge(width = 1)) +
geom_bar(stat = "identity", position = "dodge") +
labs(
x = "FPS",
y = "Game",
fill = "",
title = "Gaming Benchmarks July 2023",
subtitle = "See spec sheet for specific computer configuration") +
scale_fill_manual(values = c("AVG FPS" = "dodgerblue2", "1% Lows" = "firebrick3", "0.1% Lows" = "darkorange1")) +
#original
#scale_fill_manual(values = c("Avg FPS" = "darkblue", "1% Low FPS" = "maroon", "0.1% Low FPS" = "yellow")) +
scale_x_continuous(breaks = seq(0, 500, by = 100),
limits = c(0, 500)) +
#Reversing the legend does work in this case, but like in the KDL study I got around this by manually defining the factor levels for each variable
guides(fill = guide_legend(reverse = TRUE)) +
theme_bw()
fps_bar