|
| 1 | +#------------------------------------------------------------------------------- |
| 2 | +# Copyright (c) 2024 Arjuna Technologies, Newcastle upon Tyne. All rights reserved. |
| 3 | +# |
| 4 | +# This program and the accompanying materials |
| 5 | +# are made available under the terms of the GNU Public License v3.0. |
| 6 | +# |
| 7 | +# You should have received a copy of the GNU General Public License |
| 8 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 9 | +#------------------------------------------------------------------------------- |
| 10 | + |
| 11 | +.perf.reference.filename <- 'perf_files/default_perf_profile.csv' |
| 12 | + |
| 13 | +.perf.reference <- NULL |
| 14 | + |
| 15 | +.load.pref <- function() { |
| 16 | + .perf.reference <<- read.csv(.perf.reference.filename, header = TRUE, sep = ",") |
| 17 | +} |
| 18 | + |
| 19 | +perf.reference.save <- function(perf.ref.name, rate, tolerance.lower, tolerance.upper) { |
| 20 | + if (is.null(.perf.reference)) |
| 21 | + load.pref() |
| 22 | + |
| 23 | + .perf.reference[nrow(.perf.reference)+1,] <- c(perf.ref.name, rate, tolerance.lower, tolerance.upper) |
| 24 | + |
| 25 | + write.csv(.perf.reference, .perf.reference.filename, row.names = FALSE) |
| 26 | + |
| 27 | + .perf.reference <<- .perf.reference |
| 28 | +} |
| 29 | + |
| 30 | +perf.reference.rate <- function(perf.ref.name) { |
| 31 | + if (is.null(.perf.reference)) |
| 32 | + .load.pref() |
| 33 | + |
| 34 | + return(as.numeric(.perf.reference[which(.perf.reference$refer_name == perf.ref.name),]$rate)) |
| 35 | +} |
| 36 | + |
| 37 | +perf.reference.tolerance.lower <- function(perf.ref.name) { |
| 38 | + if (is.null(.perf.reference)) |
| 39 | + .load.pref() |
| 40 | + |
| 41 | + return(as.numeric(.perf.reference[which(.perf.reference$refer_name == perf.ref.name),]$lower_tolerance)) |
| 42 | +} |
| 43 | + |
| 44 | +perf.reference.tolerance.upper <- function(perf.ref.name) { |
| 45 | + if (is.null(.perf.reference)) |
| 46 | + .load.pref() |
| 47 | + |
| 48 | + return(as.numeric(.perf.reference[which(.perf.reference$refer_name == perf.ref.name),]$upper_tolerance)) |
| 49 | +} |
| 50 | + |
0 commit comments