Add metrics reporting to SkFiddle.

Also update the headers for template.cpp while we're here.

BUG=skia:
R=mtklein@google.com

Author: jcgregorio@google.com

Review URL: https://codereview.chromium.org/312373002
This commit is contained in:
jcgregorio 2014-06-06 06:30:31 -07:00 committed by Commit bot
parent a494a91a1d
commit 659988168a
2 changed files with 17 additions and 3 deletions

View File

@ -18,6 +18,7 @@
#include "SkBlurDrawLooper.h"
#include "SkBlurImageFilter.h"
#include "SkBlurMaskFilter.h"
#include "SkBlurTypes.h"
#include "SkCanvas.h"
#include "SkChecksum.h"
#include "SkChunkAlloc.h"
@ -120,7 +121,6 @@
#include "SkRefCnt.h"
#include "SkRegion.h"
#include "SkRRect.h"
#include "SkRTreePicture.h"
#include "SkScalar.h"
#include "SkShader.h"
#include "SkSize.h"
@ -139,7 +139,6 @@
#include "SkTemplates.h"
#include "SkTestImageFilters.h"
#include "SkThread.h"
#include "SkTileGridPicture.h"
#include "SkTileImageFilter.h"
#include "SkTime.h"
#include "SkTInternalLList.h"
@ -151,6 +150,7 @@
#include "SkTypes.h"
#include "SkUnPreMultiply.h"
#include "SkUtils.h"
#include "SkVertState.h"
#include "SkWeakRefCnt.h"
#include "SkWriteBuffer.h"
#include "SkWriter32.h"

View File

@ -17,6 +17,7 @@ import (
"io/ioutil"
"log"
"math/rand"
"net"
"net/http"
"os"
"os/exec"
@ -31,11 +32,12 @@ import (
"github.com/fiorix/go-web/autogzip"
_ "github.com/go-sql-driver/mysql"
_ "github.com/mattn/go-sqlite3"
"github.com/rcrowley/go-metrics"
)
const (
RESULT_COMPILE = `../../experimental/webtry/safec++ -DSK_GAMMA_SRGB -DSK_GAMMA_APPLY_TO_A8 -DSK_SCALAR_TO_FLOAT_EXCLUDED -DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=1 -DSK_SUPPORT_GPU=0 -DSK_SUPPORT_OPENCL=0 -DSK_FORCE_DISTANCEFIELD_FONTS=0 -DSK_SCALAR_IS_FLOAT -DSK_CAN_USE_FLOAT -DSK_SAMPLES_FOR_X -DSK_BUILD_FOR_UNIX -DSK_USE_POSIX_THREADS -DSK_SYSTEM_ZLIB=1 -DSK_DEBUG -DSK_DEVELOPER=1 -I../../src/core -I../../src/images -I../../tools/flags -I../../include/config -I../../include/core -I../../include/pathops -I../../include/pipe -I../../include/effects -I../../include/ports -I../../src/sfnt -I../../include/utils -I../../src/utils -I../../include/images -g -fno-exceptions -fstrict-aliasing -Wall -Wextra -Winit-self -Wpointer-arith -Wno-unused-parameter -m64 -fno-rtti -Wnon-virtual-dtor -c ../../../cache/%s.cpp -o ../../../cache/%s.o`
LINK = `../../experimental/webtry/safec++ -m64 -lstdc++ -lm -o ../../../inout/%s -Wl,--start-group ../../../cache/%s.o obj/experimental/webtry/webtry.main.o obj/gyp/libflags.a libskia_images.a libskia_core.a libskia_effects.a obj/gyp/libjpeg.a obj/gyp/libetc1.a obj/gyp/libwebp_dec.a obj/gyp/libwebp_demux.a obj/gyp/libwebp_dsp.a obj/gyp/libwebp_enc.a obj/gyp/libwebp_utils.a libskia_utils.a libskia_opts.a libskia_opts_ssse3.a libskia_ports.a libskia_sfnt.a -Wl,--end-group -lpng -lz -lgif -lpthread -lfontconfig -ldl -lfreetype`
LINK = `../../experimental/webtry/safec++ -m64 -lstdc++ -lm -o ../../../inout/%s -Wl,--start-group ../../../cache/%s.o obj/experimental/webtry/webtry.main.o obj/gyp/libflags.a libskia_images.a libskia_core.a libskia_effects.a obj/gyp/libjpeg.a obj/gyp/libetc1.a obj/gyp/libSkKTX.a obj/gyp/libwebp_dec.a obj/gyp/libwebp_demux.a obj/gyp/libwebp_dsp.a obj/gyp/libwebp_enc.a obj/gyp/libwebp_utils.a libskia_utils.a libskia_opts.a libskia_opts_ssse3.a libskia_ports.a libskia_sfnt.a -Wl,--end-group -lpng -lz -lgif -lpthread -lfontconfig -ldl -lfreetype`
DEFAULT_SAMPLE = `void draw(SkCanvas* canvas) {
SkPaint p;
@ -112,6 +114,8 @@ var (
gitHash = ""
gitInfo = ""
requestsCounter = metrics.NewRegisteredCounter("requests", metrics.DefaultRegistry)
)
// flags
@ -280,6 +284,15 @@ func init() {
}
}()
metrics.RegisterRuntimeMemStats(metrics.DefaultRegistry)
go metrics.CaptureRuntimeMemStats(metrics.DefaultRegistry, 1*time.Minute)
// Start reporting metrics.
// TODO(jcgregorio) We need a centrialized config server for storing things
// like the IP address of the Graphite monitor.
addr, _ := net.ResolveTCPAddr("tcp", "10.240.159.195:2003")
go metrics.Graphite(metrics.DefaultRegistry, 1*time.Minute, "webtry", addr)
writeOutAllSourceImages()
}
@ -733,6 +746,7 @@ func cleanCompileOutput(s, hash string) string {
// mainHandler handles the GET and POST of the main page.
func mainHandler(w http.ResponseWriter, r *http.Request) {
log.Printf("Main Handler: %q\n", r.URL.Path)
requestsCounter.Inc(1)
if r.Method == "GET" {
code := DEFAULT_SAMPLE
source := 0