統計與計量‎ > ‎應用總覽‎ > ‎

應用程式效能分析

資料結構

統計分析圖表

Call:
lm(formula = TXN_TIME ~ TXN_NO)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.12534 -0.05211  0.00262  0.04614  0.32040 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)  
(Intercept)  6.138e-01  2.889e-01   2.125   0.0433 *
TXN_NO      -7.113e-07  2.533e-03   0.000   0.9998  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 0.09075 on 26 degrees of freedom
Multiple R-squared: 3.034e-09,	Adjusted R-squared: -0.03846 
F-statistic: 7.888e-08 on 1 and 26 DF,  p-value: 0.9998 

GNU-R

library(DBI)
library(RMySQL)
library(car)

GetDB <- function (SQL) {
  mySQL.Connection <- dbConnect(MySQL(), host=mySQL.Host, user=mySQL.User, password=mySQL.Password, db=mySQL.Schema)

  ResultSet <- dbGetQuery(mySQL.Connection, SQL)
  dbDisconnect(mySQL.Connection)
  
  ResultSet
}

SaveScatterPlotGraphics <- function(pngFileName, formula, graphicsTitle, graphicsXTitle, graphicsYTitle) {
  png(file=pngFileName)
    scatterplot(formula, reg.line=lm, smooth=TRUE, spread=TRUE, boxplots='xy', 
span=0.5, main=graphicsTitle, xlab=graphicsXTitle, ylab=graphicsYTitle) dev.off() } mySQL.Host <- "127.0.0.1" mySQL.User <- "nmon" mySQL.Password <- "nmon" mySQL.Schema <- "nmon" R.Chart.Folder <- "/var/nmon/Results/Graphics" R.Analysis.Folder <- "/var/nmon/Results/Analysis" mySQL.SQL <- paste("SELECT DISTINCT DATE_DAY FROM "
, mySQL.Schema,
".reportdb ORDER BY DATE_DAY LIMIT 30", sep="") mySQL.DATA <- GetDB(mySQL.SQL) Date.Start <- mySQL.DATA$DATE_DAY[1] Date.End <- mySQL.DATA$DATE_DAY[length(mySQL.DATA$DATE_DAY)] mySQL.SQL <- paste("SELECT TO_DAYS(DATE_DAY) AS TXN_DATE, AVG(TXNNO) AS AVG_TXNNO, AVG(AVGTIME) AS AVG_TXNTIME FROM ",
mySQL.Schema,
".reportdb WHERE DATE_DAY BETWEEN '", Date.Start, "' AND '", Date.End,
"' GROUP BY DATE_DAY ORDER BY DATE_DAY"
, sep="") mySQL.DATA <- GetDB(mySQL.SQL) TXN_NO <- (mySQL.DATA$AVG_TXNNO) / 1000 TXN_TIME <- (mySQL.DATA$AVG_TXNTIME) TXN_DATE <- (mySQL.DATA$TXN_DATE) mySQL.Chart <- paste(R.Chart.Folder, "/", "AVG_TXN.png", sep="") SaveScatterPlotGraphics(mySQL.Chart, TXN_NO~TXN_DATE, "TXN.NO~TXN.DATE (Last 30 Days)", "Day #", "TXN.NO (x1000)") mySQL.Chart <- paste(R.Chart.Folder, "/", "AVG_RESPONSE_TIME.png", sep="") SaveScatterPlotGraphics(mySQL.Chart, TXN_TIME~TXN_DATE,
"TXN.RESPONSE_TIME~TXN.DATE (Last 30 Days)"
, "Day #", "TXN.RESPONSE.TIME") mySQL.Chart <- paste(R.Chart.Folder, "/", "AVG_TXN_TIME.png", sep="") SaveScatterPlotGraphics(mySQL.Chart, TXN_TIME~TXN_NO,
"TXN.RESPONSE_TIME~TXN.NO (Last 30 Days)"
, "TXN.NO (x1000)", "TXN.RESPONSE.TIME") sink(paste(R.Analysis.Folder, "/", "AVG_TXN_TIME.txt", sep="")) summary(lm(TXN_TIME~TXN_NO)) sink() mySQL.SQL <- paste("SELECT APSVR, TO_DAYS(DATE_DAY) AS TXN_DATE, AVG(TXNNO) AS AVG_TXNNO, AVG(AVGTIME) AS AVG_TXNTIME FROM ",
mySQL.Schema, ".reportdb WHERE DATE_DAY BETWEEN '", Date.Start, "' AND '", Date.End,
"' GROUP BY APSVR, DATE_DAY ORDER BY APSVR, DATE_DAY"
, sep="") mySQL.DATA <- GetDB(mySQL.SQL) APPSVR <- (mySQL.DATA$APSVR) TXN_NO <- (mySQL.DATA$AVG_TXNNO) / 1000 TXN_TIME <- (mySQL.DATA$AVG_TXNTIME) TXN_DATE <- (mySQL.DATA$TXN_DATE) mySQL.Chart <- paste(R.Chart.Folder, "/", "AVG_SVR_TXN.png", sep="") SaveScatterPlotGraphics(mySQL.Chart, TXN_NO~TXN_DATE | APPSVR,
"TXN.NO~TXN.DATE by APPSVR (Last 30 Days)"
, "Day #", "TXN.NO (x1000)") rm(list=(ls()))
ċ
ReportDB-AVG_TXN.R
(3k)
李智,
2012年7月4日 上午8:58