w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Adding rails apps to nginx avoiding high load time on 1st access
Unicorn sounds like it might be a better fit for your deployment scenario. You can keep nginx up front, but instead of loading rails itself, it will just connect to a unicorn Unix socket. Further, you can reload your application with new code gracefully, while nginx stays up and Unicorn swaps out backend quietly.

Categories : Ruby On Rails

FacesServlet.service() method eating too much time while serving requests (high self-time)
Hmmm, what are the parameters of FacesServlet.service()? is that servlet request and servlet response? seems like a typical request from your browser and response from your app/server. It is quite obvious that your code-and-or-usage-of-your-dependencies are the cause of the time it takes for FacesServlet.service() to complete. Wow, it seems as though your usage of prettyfaces dependency is causing most of the lengthy time it takes for FacesServlet.service() to complete. On Sat, Sep 7, 2013 at 2:24 AM, Anton Gavazuk wrote: Process an incoming request, and create the corresponding response, by executing the request processing lifecycle. If the request and response arguments to this method are not instances of HttpServletRequest and HttpServletResponse, respectively, the res

Categories : Java

Joda Date-Time: Capture Date time(UTC) and convert to byte/byte array
DateTime date = new DateTime().withZone(DateTimeZone.UTC). withChronology(ISOChronology.getInstanceUTC()); If all you want is UTC you can use plain long time = System.currentTimeMillis(); BTW, all computers actually use GMT rather than supporting UTC. e.g. no leap seconds. I don't know why there is T and z there in output. ISO 8601 standard. Now I have to convert it to bytes/bytes array. There are many different ways to do this. Can you say how you need the translation to be performed? As per the standard I am following they have given an example of result after converion December 15,2005 at 17:35:19.000 ==> 07D5 0C 0F 11 23 13 0000Hex Which standard you referring to? If 07D5 0C 0F 11 23 13 0000 was the time in milli-seconds you would be in t

Categories : Java

JMX: CPU + Blocked + Wait time = Wall time?
CPU time tells you how much time the thread took utilizing the CPU, i.e. actually executing code. Block or wait times increase if the thread had been suspended because of e.g. waiting for I/O or entering a monitor. However, it's up to the JVM and OS to assign CPU time to threads and processes. They may choose to suspend a thread or process and resume another one at any time, if necessary. So the thread may be in a state where it is neither blocked nor waiting but just not executing. This will add to wall time but not blocked/wait time. The CPU time value comes from the operating system. I checked OpenJDK 7 for Linux systems, so it might be different on other platforms. Either fast_thread_cpu_time() or slow_thread_cpu_time() is called to calculate CPU time for threads. Both functions are

Categories : Java

Do I need to do anything with a SIGCHLD handler if I am just using wait() to wait for 1 child to finish at a time?
If you do not care about the exit status of forked children, then you can ignore SIGCHLD. signal(SIGCHLD, SIG_IGN); If you do care about the exit status, you can install a signal handler, and perform a waitpid() call within the signal handler to reap the exit status values from the exited child processes. This call should be in a loop, until there are not more exited children. You would use -1 in the first parameter, and WNOHANG in the last parameter to wait for any child in a non-blocking way. If waitpid() returns 0, it means the call succeeded, but there are no more children to wait on. void sigchld_handler (int sig) { assert(sig == SIGCHLD); int status; pid_t child; while ((child = waitpid(-1, &status, WNOHANG)) > 0) { /*...do something with exited chi

Categories : C

High performance real time project .NET, SQL Server
I’d start of by making estimates based on following data with the goal of estimation number of requests per minute or second. Average number of moving markers at any time. If you have 200 vehicles to track how many do you expect to be moving simultaneously? Does time of the day matter? If it does make sure you make calculations based on the peak hours. How many simultaneous requests from users do you expect? If you have 800 users are they going to be using the application throughout the whole day or only several times a day or once a week? Once you get the data multiply it by at least 3. This will accommodate for all false assumptions you may have made in the calculations and allow for future growth. Once you get the final number it will be a lot easier to decide whether you need

Categories : C#

MongoDB High Avg. Flush Time - Write Heavy
Without seeing any disk statistics, I am of the opinion that you are saturating your disks. This can be checked with iostat -xmt 2, and checking the %util column. Please don't disable journalling - you will only cause more issues later down the line when your machine crashes. Separating collections will have no effect. Separating databases may, but if you're IO bound, this will do nothing to help you. Options If I am correct, and your disks are saturated, adding more disks in a RAID 10 configuration will vastly help performance and durability - more so if you separate the journal off to an SSD. Assuming that this machine is a single server, you can setup a replicaset and send your read queries there. This should help you a fair bit, but not as much as the disks.

Categories : Mongodb

How to detect High CPU and long response time issues with Asp.NET Web Api
A good option would be to take a mini-dump using something like Process Explorer and then inspect it with WinDBG or otherwise, to see what the threads are doing and so forth. I have a good blog post about how to do it here: http://www.haneycodes.net/but-it-didnt-happen-in-dev-or-qa/

Categories : C#

gcc - high execution time by copying a double into a integer
Just by looking to the information you've provided, it can be because of the stalls happening when you transfer data from a floating point register to an arm register. This Debian page on arm floating modes claims, it can take around ~20 cycles for such operation. Try to use floating point variables as much as possible, for example convert sSample to a float. Your arm926ej-s (vfpv2) should provide 32 single precision (16 double precision) registers.

Categories : Gcc

high net IO time in weblogic.net.http.MessageHeader.isHttp
Spending most of your application threads' time in network I/O is normal when using a blocking web framework. Moving bits over a network is orders of magnitude slower than, say, moving bits in and out of memory in a single computer. Low level networking protocols are designed to guarantee a message gets where it's going without being changed en route, not to do that particularly fast.

Categories : Java

Convert high resolution clock time into an integer (Chrono)
You can use a std::chrono::duration_cast: http://en.cppreference.com/w/cpp/chrono/duration/duration_cast

Categories : C++

How to wait for time interval?
one simple solution to your problem would be to increment a counter every time you call your function. Then at the end of the callback have it emit an event. listen to that event and each time it's triggered increment a separate counter. When the two counters are equal you can move on. This would look something like this var function_call_counter = 0; var function_complete_counter = 0; var self = this; for(var i = 0; i < time_to_call; i++){ function_call_counter++; api_call(function(){ self.emit('api_called'); }); } this.on('api_called', function(){ function_complete_counter++; }); var id = setInterval(function(){ if(function_call_counter == function_complete_counter){ move_on(); clearInterval(id); // This stops the checking

Categories : Node Js

wait for specifed time without using while C
You can use sleep() to pause your application for the given amount of seconds, or you can use usleep() to pause your application for the given amount of microseconds. You can also explore the blocking properties of select() to have a microsecond precision pausing. Some applications prefer to do that, don't ask me why. About your while() loop, never do that. It is not pausing. Your application will loop using 99% of the CPU until the time has elapsed. Its a very dumb way of doing that. Also, its preferable that you use time() to get the current UNIX time and use that as reference, and difftime() to get the time delta in seconds to use with sleep(). You may have problems with clock(), because this function on a 32-bit system will return the same number every ~72 minutes, and you will of

Categories : C

Wait operation time out mvc
In order to avoid wait operation timed out exception when running very long queries, change the SQL command properties and allow the command to wait longer before calling the timeout. using System; using System.Data.SqlClient; /// public class A { /// public static void Main() { string connectionString = ""; // Wait for 5 second delay in the command string queryString = "waitfor delay '00:00:05'"; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand command = new SqlCommand(queryString, connection); // Setting command timeout to 1 second command.CommandTimeout = 1; try { command.ExecuteNonQuery(); } catch (SqlException e) {

Categories : C#

Translating time stamps (start, end) into time series data. Errors with align.time() and colnames
This is not an answer to your problem. Honestly it is not clear for me the transition between the data you show in the image and the example of your data. It seems like that you can't reproduce this data. So Here a function to generate a reproducible example of your data. I think it can be at least useful, to validate your model. function to sample data library(reshape2) start.min <- as.POSIXct("2013-01-01 00:00:00 PST") hours.min <- format(seq(start.min, length.out=24*60, by = "mins"), '%H:%M') ## function to generate a trip sample ## min.dur : minimal duration of a trip ## max.dur : maximal duration of a trip ## min.trip : minimal number of trips that a user can do gen.Trip <- function(min.dur=3,max.dur=10,min.trip=100){ ## gen

Categories : R

How to deal with time out exception for wait.until
resolved my problem, by modifing codes like below: driver=webdriver.Firefox() driver.get('https://www-01.ibm.com/products/hardware/configurator/americas/bhui/launchNI.wss') driver.find_element_by_id("modelnumber").send_keys("7383AC1") driver.find_element_by_name("submit").click() element1 = driver.find_element_by_xpath("//label[contains(text(),'SLES for SAP Apps 8 Skt Virt Unlimited Subs Only 5Yr (5731SLX)')]") id=element1.get_attribute('for') driver.find_element_by_id(id).click() print driver.title wait=ui.WebDriverWait(driver,300) image1=driver.find_element_by_xpath("//img[@src='//www.ibm.com/i/c.gif']") print image1.get_attribute('class') div1=driver.find_element_by_id("genMask_c") wati.until(EC.staleness_of(driver.find_element_by_id("genMask_c")), 'visible') driver.find_element_by

Categories : Python

How to make it so that theres a wait time between dialog
You could try something like... import java.util.Scanner; public class Test { public static void main(String[] args) { System.out.println("Stranger: Good morning"); delay(500); System.out.println("Stranger: you had a terrible Dream.."); delay(500); System.out.println("Stranger: what is your name?"); System.out.print("Name:"); Scanner kbReader = new Scanner(System.in); String s = kbReader.next(); System.out.println("Nice to meet you " + s); System.out.println("my name is Master Wizard."); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); } public static void delay(int millis) { tr

Categories : Java

How do I tell PHP to wait for an SQL query only for a certain amount of time?
Since the query is not sensitive, you should cache the results instead of hitting the database each time. PHP provides mysqlnd-qc the (qc is for query cache) which works with APC and friends to cache the results of MySQL queries. The other option is to cache the template instead. Smarty has this included. This means you render the page once, and then only render it after a certain fixed time.

Categories : PHP

Time Profiler - Wait for app launch
"see what methods are taking so long" Do you suppose some method (or a few) are sopping up a lot of CPU time in themselves or by calling other methods that do? If so, it will be easy to fix, but it's Not Likely. More likely the time is spent in I/O of one sort or another, and you need to figure out why, not where. If you're able to start it under a debugger (say by using @ChrisTruman's recommendation), then all you need to do is interrupt it with Ctrl-C, Ctrl-Break, Escape, or whatever key combination interrupts it. Do this during the time when, subjectively, it is slow. Let's suppose the startup is taking three times longer than you think it should. If that's so, that means two thirds of the time is spent doing the unnecessary I/O or whatever it is. That means each time you interr

Categories : Iphone

Improve Nginx Server Response Time
I also use Ubuntu 12.04LTS with nginx and ngx_pagespeed You can follow this link to compile nginx with ngx_pagespeed: https://github.com/pagespeed/ngx_pagespeed#how-to-build You can increase your score without requiring to modify your code. If you want to get a perfect PageSpeed score, this article might help you: http://www.appneta.com/blog/bootstrap-pagespeed . https://github.com/danriti/bootstrap-pagespeed

Categories : Nginx

identify the row in my time vector where the time is 5 seconds before the last printed time, times are however in milliseconds
For your sample vector (let's call it t): find(t < t(end) - 5000, 1, 'last') ans = 4 For the full matrix, it's almost the same thing: find(matrix(:,2) < matrix(end,2) - 5000, 1, 'last')

Categories : Matlab

HTTP Get request | Long wait time
You basically need to check these things : Load of the server Load of Apache HTTPd (is it overloaded of queries? When the maximum is reached, subsequent requests become slow) Load of the database and/or slow queries All of this depends on what this URL is doing behind. Without knowing it, can't help much.

Categories : Performance

Python - How to wait on both queue and a socket on same time
You can do something along these lines: def check_for_message(queue,socket,sock_accept_size=512): socket.setblocking(0) while True: try: sock_msg=socket.recv(sock_accept_size) except socket.error: """Do stuff if there is no message""" sock_msg=None try: que_msg=queue.get() except Queue.Empty: """Do stuff if there is no message""" que_msg=None yield (que_msg,sock_msg) Then you can iterate through it using: for que_message,sock_message in check_for_message(que_instance,socket_instance): print que_message,sock_message

Categories : Python

How can I wait for a period of time after a button is clicked?
Use a CountDownTimer: CountDownTimer timer = new CountDownTimer(4000, 1000) { @Override public void onFinish() { *function containing the second statement* } @Override public void onTick(long millisLeft) { // not ticking } }; and in the onClick method in the click listener use: timer.start();

Categories : Android

How to wait for all goroutines to finish without using time.Sleep?
You can use sync.WaitGroup. Quoting the linked example: package main import ( "net/http" "sync" ) func main() { var wg sync.WaitGroup var urls = []string{ "http://www.golang.org/", "http://www.google.com/", "http://www.somestupidname.com/", } for _, url := range urls { // Increment the WaitGroup counter. wg.Add(1) // Launch a goroutine to fetch the URL. go func(url string) { // Decrement the counter when the goroutine completes. defer wg.Done() // Fetch the URL. http.Get(url) }(url) } // Wait for all HTT

Categories : Go

jQuery rcarousel - slide wait time
What you're looking for is the interval property on the auto option. Use the following JavaScript to set: $(function () { $("#carousel").rcarousel({ auto: { enabled: true, interval: 1000} }); }); note: currently set to 1 second for demo, but add another 0 if you'd like it to take 10 seconds jsFiddle

Categories : Javascript

How to compare Starting time and End time of a event with existing events of same time on same day?
You can use 24 hour format to solve this in your logic. you have to save existing event timings in Database. whenever new event timings entered, you need to compare with existing both start & end timings with previous ones. For Example: Event1: x1 to y1 Event2; x2 to y2 if(x2==x1 && y2==y1) if(x2>x1 &&x2<y1) andif(y2<y1) ...so on based on your requirement.

Categories : Asp Net

Python time.sleep vs busy wait accuracy
This is sort of a duplicate question, but I'll try to answer it here anyway to the best of my ability. The sleep function is an OS call that differs from busy wait in that it doesn't block the thread. If you have a multi-threaded script though, it shouldn't block the other threads. The sleep function is inaccurate in Windows because it is not a realtime OS (not sure what that means). If you are looking strictly for accuracy of the wait, busy wait is the way to go. Otherwise, time.sleep() is probably preferred. The reason the OS call to sleep is inaccurate is probably because it relies on the OS to return at the correct time, and is reliant on the precision of the OS's scheduler.

Categories : Python

Very long "Wait" time on ajax requests MVC4
I see following reason: you have breakpoint somewhere in the code. Probably it is in JavaScript (after you close browser request go immediately). So disable your breakpoints or if it won't help try to pause debugger to see what's going on.

Categories : Asp Net Mvc

pygame.time.wait() makes the window freez
Two things: When you run a loop like this: for x in range(10, 101, 10): pygame.draw.rect(DS, BGCOLOR, (150 - x,50,x,100)) pygame.display.update() you draw your animation, but pygame has no opportunity to handle the messages it gets from your operation system. To avoid that, you should call pygame.event.pump() or pygame.event.get() inside the loop. From the docs: pygame.event.pump() For each frame of your game, you will need to make some sort of call to the event queue. This ensures your program can internally interact with the rest of the operating system. If you are not using other event functions in your game, you should call pygame.event.pump() to allow pygame to handle internal actions. This function is not necessary if your program is consistently pr

Categories : Python

Wordpress Website too much wait Time with Pingdom Tool
I did a profiling an a wordpress installation once, being embarrassed by such a loading time. It turned out that the time can be reduced by half with some opcode cache like APC, and another half been taken by parsing an enormous .po localization file. Did a quick patch to cache it in a php array and finally got loading time within a second (which is still too much but barely bearable). Now I am thinking that removing useless languages from that gettext file would also help. The profiling itself was as silly as adding microtime(1)-based labels all ove the code

Categories : PHP

Java - Wait for space or return after a certain amount of time
I believe you need to use the ExecturerService and Future to achieve this. You can set the execution time for the future to finish itself. You need to wrap your code waiting for the user input in run method of a Thread class. Once you do that and suppose you call you class as Task, then you can do this: public class Test { public static void main(String[] args) throws Exception { ExecutorService executor = Executors.newSingleThreadExecutor(); Future<String> future = executor.submit(new Task()); try { System.out.println("Started.."); System.out.println(future.get(5, TimeUnit.SECONDS)); System.out.println("Finished!"); } catch (TimeoutException e) { System.out.println("Terminated!"); }

Categories : Java

Adjusting audio volume in real time from byte[]?
I suggest you wrap your byte array in a ByteBuffer (not forgetting to set its .order() to little endian), read a short, manipulate it, write it again. Sample code: // Necessary in order to convert negative shorts! private static final int USHORT_MASK = (1 << 16) - 1; final ByteBuffer buf = ByteBuffer.wrap(audioSamples) .order(ByteOrder.LITTLE_ENDIAN); final ByteBuffer newBuf = ByteBuffer.allocate(audioSamples.length) .order(ByteOrder.LITTLE_ENDIAN); int sample; while (buf.hasRemaining()) { sample = (int) buf.getShort() & USHORT_MASK; sample *= volume; newBuf.putShort((short) (sample & USHORT_MASK)); } return newBuf.array();

Categories : Java

How to make a function to wait for a specific time in Windows phone?
If your animation is a Storyboard then it has a Completed event (MSDN link) for just this purpose. Your call to Thread.Sleep() was probably being run on the same thread as the animation and so was stopping the animation from running while it was sleeping. If you really want to go down this route then you'll need to move your sleep call to a different thread. If you really want to use threads, a simple way to do it is: System.Threading.ThreadPool.QueueUserWorkItem(obj => { System.Threading.Thread.Sleep(5000); Dispatcher.BeginInvoke(() => { MessageBox.Show("after delay"); }); });

Categories : C#

lock wait time out exceeded in java jdbc transaction
You can set the lock timeout for your database explicitly (as probably your updates keep the transaction open for too long). For MySQL you can find the detailed instructions here Basically you set it up with the command like this in /etc/my.cnf permanently with this line [mysqld] innodb_lock_wait_timeout=120 and restart mysql. If you cannot restart mysql at this time, run this: SET GLOBAL innodb_lock_wait_timeout = 120; You could also just set it for the duration of your session SET innodb_lock_wait_timeout = 120;

Categories : Java

Correct wait to poll for loading a file every hour until a certain time
Thread.Sleep is a bad idea, use a timer (System.Timers) to do the job. See http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx for info on Timer class

Categories : C#

jQuery/JavaScript wait for page to load, but no shorter than specified time
You certainly don't need $(window).load... within the setTimeout function. In fact, putting it within the timeout will ensure that it never executes since the window.load event will have already fired before you assign it your function to fadeOut the overlay. I've adjusted my code based on your feedback. The basic principle is to determine how long it took to get everything ready and then reduce the timeout based on the time already elapsed. This way your fastest connections will still get a delay while your slowest connections will execute the fadeout immediately. Live Demo //Put this line in a script tag as high up on the page as possible window.timeInMs = Date.now(); Instead of document.ready which executes after the document is loaded, use window.load which executes after the

Categories : Javascript

Python header print one time for every time I run the script not each time
I thoroughly apologize for the previous versions. There was a tiny detail that I was missing but I've fixed it now. Here's the correct code: #--- Open the file + write on it --- f = open('out.csv','a') prev_data = open('out.csv', 'r').read() header = "Datetime,Location,Temperature,current_condition " # Add a header only if the file is empty if prev_data == '': f.write(header) date = str(now.month) + "/" + str(now.day) + "/" + str(now.year) + " " + str(now.hour) + ":" + str(now.minute) + ":" + str(now.second) f.write(','.join([date,locations,str(temp_f),weather])) f.write(' ') f.close() # --- And Close the file ---

Categories : Python

How to display a time in the user's local time zone if I have that time in UTC?
You can use the method localtime: {% load tz %} {% localtime on %} {{ value }} {% endlocaltime %} {% localtime off %} {{ value }} {% endlocaltime %}

Categories : Django

Non-blocking read on subprocess PIPE in python, one byte at a time
As @Markku K. pointed out, you should use bufsize=0 to read one byte at a time. Your code doesn't require a non-blocking read. You can simplify it: import sys from functools import partial from subprocess import Popen, PIPE p = Popen([sys.executable, "test.py"], stdout=PIPE, bufsize=0) for b in iter(partial(p.stdout.read, 1), b""): print b # it should print as soon as `sys.stdout.flush()` is called # in the test.py p.stdout.close() p.wait() Note: reading 1 byte at a time is very inefficient. Also, in general, there could be a block-buffering issue that sometimes can be solved using pexpect, pty modules or unbuffer, stdbuf, script command-line utilities. For Python processes you could use -u flag to force unbuffering (binary layer) of stdin, stdout, stderr streams.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.