use of org.polymap.core.runtime.Timer in project polymap4-core by Polymap4.
the class WebDavServer method service.
public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
Timer timer = new Timer();
HttpServletRequest req = (HttpServletRequest) servletRequest;
HttpServletResponse resp = (HttpServletResponse) servletResponse;
DefaultSessionContextProvider contextProvider = FsPlugin.getDefault().sessionContextProvider;
try {
Request request = new io.milton.servlet.ServletRequest(req, servletRequest.getServletContext());
Response response = new io.milton.servlet.ServletResponse(resp);
threadRequest.set(request);
threadResponse.set(response);
Auth auth = request.getAuthorization();
log.debug("Auth: " + auth);
// map/create session context
req.getSession(true);
if (auth != null) {
contextProvider.mapContext(auth.getUser(), true);
log.debug("SessionContext: " + SessionContext.current());
}
httpManager.process(request, response);
log.debug("Request: " + Request.Header.ACCEPT_ENCODING.code + ": " + request.getHeaders().get(Request.Header.ACCEPT_ENCODING.code) + " --> Response: " + Response.Header.CONTENT_ENCODING.code + ": " + response.getHeaders().get(Response.Header.CONTENT_ENCODING.code));
log.debug("Response: " + response.getStatus());
} finally {
if (contextProvider.currentContext() != null) {
contextProvider.unmapContext();
}
threadRequest.set(null);
threadResponse.set(null);
servletResponse.getOutputStream().flush();
servletResponse.flushBuffer();
}
log.info("WebDAV request: " + timer.elapsedTime() + "ms");
}
use of org.polymap.core.runtime.Timer in project polymap4-core by Polymap4.
the class PredefinedColorMapEditor method main.
// Test ***********************************************
public static void main(String[] args) throws Exception {
File f = new File("/home/falko/Data/ncrast/elevation_4326.tif");
AbstractGridFormat format = GridFormatFinder.findFormat(f);
AbstractGridCoverage2DReader reader = format.getReader(f);
String[] names = reader.getGridCoverageNames();
GridCoverage2D grid = reader.read(names[0], null);
GridGeometry2D geometry = grid.getGridGeometry();
GridEnvelope gridRange = geometry.getGridRange();
int w = gridRange.getHigh(0);
int h = gridRange.getHigh(1);
// all
Timer timer = new Timer();
double min = Double.MAX_VALUE;
double max = Double.MIN_VALUE;
int c = 0;
double[] buf = new double[1];
for (int x = 0; x < w; x++) {
for (int y = 0; y < h; y++) {
double[] value = grid.evaluate(new GridCoordinates2D(x, y), buf);
min = value[0] < min ? value[0] : min;
max = value[0] > max ? value[0] : max;
c++;
}
}
System.out.println("min/max: " + min + ".." + max + " (" + c + " in " + timer.elapsedTime() + "ms)");
// random
timer.start();
double[] minMax = new PredefinedColorMapEditor().minMax(grid);
System.out.println("min/max: " + minMax[0] + ".." + minMax[1] + " (" + c + " in " + timer.elapsedTime() + "ms)");
// final DefaultProcessor proc = new DefaultProcessor(null);
// for (Operation o : proc.getOperations() ){
// System.out.println(o.getName());
// System.out.println(o.getDescription());
// System.out.println();
// }
}
use of org.polymap.core.runtime.Timer in project polymap4-core by Polymap4.
the class PerformanceEventTests method testSyncPublishNoDelay.
public void testSyncPublishNoDelay() throws InterruptedException {
count = 0;
size = 100000;
// handler
Object handler = new Object() {
@EventHandler(scope = Scope.JVM)
public void countEvent(PerformanceTestEvent ev) {
count++;
}
};
EventManager.instance().subscribe(handler);
// loop: publish event
Timer timer = new Timer();
for (int i = 0; i < size; i++) {
EventManager.instance().syncPublish(new PerformanceTestEvent(this));
}
log.info("sync events: " + size + " - " + timer.elapsedTime() + "ms");
assertEquals(count, size);
EventManager.instance().unsubscribe(handler);
}
use of org.polymap.core.runtime.Timer in project polymap4-core by Polymap4.
the class PerformanceEventTests method testPublishDelay.
public void testPublishDelay() throws InterruptedException {
count = 0;
size = 1000000;
// handler
Object handler = new Object() {
@EventHandler(scope = Scope.JVM, delay = 10)
public void countEvent(List<PerformanceTestEvent> evs) {
count += evs.size();
log.info(" handle delayed (10ms): " + evs.size() + " - " + count);
synchronized (this) {
notifyAll();
}
}
};
EventManager.instance().subscribe(handler, ev -> ev instanceof PerformanceTestEvent);
// loop: publish event
Timer timer = new Timer();
for (int i = 0; i < size; i++) {
EventManager.instance().publish(new PerformanceTestEvent(this));
// Thread.sleep( 10 );
}
log.info("delayed async events: " + size + " - " + timer.elapsedTime() + "ms");
// wait for results
while (count < size - 1) {
synchronized (handler) {
handler.wait(100);
}
}
log.info(" count: " + count + " - " + timer.elapsedTime() + "ms");
EventManager.instance().unsubscribe(handler);
}
use of org.polymap.core.runtime.Timer in project polymap4-core by Polymap4.
the class PerformanceEventTests method testPublishNoDelay.
public void testPublishNoDelay() throws InterruptedException {
count = 0;
size = 1000000;
// handler
Object handler = new Object() {
@EventHandler(scope = Scope.JVM)
public void countEvent(PerformanceTestEvent ev) {
count++;
synchronized (this) {
notifyAll();
}
}
};
EventManager.instance().subscribe(handler, ev -> ev instanceof PerformanceTestEvent);
// loop: publish event
Timer timer = new Timer();
for (int i = 0; i < size; i++) {
EventManager.instance().publish(new PerformanceTestEvent(this));
}
log.info("async events: " + size + " - " + timer.elapsedTime() + "ms");
// wait for results
while (count < size) {
synchronized (handler) {
handler.wait(10);
}
}
log.info(" count: " + count + " - " + timer.elapsedTime() + "ms");
EventManager.instance().unsubscribe(handler);
}
Aggregations