w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
High clock speed vs multiple cores/CPUs in a web server
There are two different situations that we can consider: - One kind of processor that is just used for calculations for a single program. In this situation, the Processor speed is more important as the user want the ability to do quickly and efficiently. Its not the case with web server. - On the other hand the processor used for multiple programs running at the same time. ( concurrent processes) The second is where multiple cores come in handy, as each program can be assigned to a separate core, thus freeing each program from 'bottle-necking' each other. - From Intel :) Software developers can no longer rely on increasing clock speeds alone to speed up single-threaded applications; instead, to gain a competitive advantage, developers must learn how to properly design their applic

Categories : PHP

Can I set an invalid value to hardware clock (Real Time Clock) on Linux
Depending on your hardware, this might be impossible. One way to make it work is to overwrite the function that you use to read the hardware clock. If you have enough tests to make sure the function itself works (and the same is true for the code which uses the function), then you can use the C preprocessor to point your code to a mock implementation that returns illegal values. That means you need to compile and link a special binary that doesn't call the actual function and run the test with that.

Categories : Linux

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++

High Speed Collisions in Unity
It turns out I only needed to got to ProjectSettings -> Time -> Fixed TimeStep There you just need to raise the number by a little bit. Be careful though, if you raise the value too much it will freeze the program.

Categories : C#

High speed data acquisiton using REST Services
Using WCF yes. I'm not sure REST is the best architectural style for the type of problem you are trying to solve. I also wonder whether HTTP is appropriate. Having said that you might want to look into CORE which is an effort to apply REST in highly constrained environments like data acquisition.

Categories : Wcf

High speed, between-frame, graphics architecture for java
instead of interacting through Graphics2D you should interact direct with image data. This is my code, with my laptop can run with 20 frame/second (fullscreen) @SuppressWarnings("serial") class TestPanel extends JPanel { int w, h; private static int WIDTH = 700; private static int HEIGHT = 500; private static final Color BACKGROUND_COLOR = Color.white; private BufferedImage bImg; private Color color = Color.black; public TestPanel() { bImg = new BufferedImage(WIDTH, HEIGHT,BufferedImage.TYPE_INT_RGB); Graphics g = bImg.getGraphics(); g.setColor(BACKGROUND_COLOR); g.fillRect(0, 0, WIDTH, HEIGHT); Timer myTimer = new Timer(10, new ActionListener() { @Override public void actionPerformed(ActionEv

Categories : Java

Is it possible to get "blur motion" by moving an object at high speed programatically
To get a blur effect in flash you need to apply a blur filter to it. You can create and apply this filter to an object in code and adjust the amount of blur as well. For a motion blur, you could apply filter and use the object's speed as a multiple for the amount of blur you want.

Categories : Actionscript

How can I change the System clock of a Linux machine by using Java?
There are two problems with this line of code: Process p = Runtime.getRuntime().exec("date --set="2011-12-07 01:20:15.962""); You did not wait for the process to complete (see also http://docs.oracle.com/javase/6/docs/api/java/lang/Process.html#waitFor()) Parameters should be separated from program name, try this: "date", "-s", "2011-12-07 01:20:15.962" Alternatively, invoke shell as the process, and pass in a line of code: .exec("sh", "-c", "date --set="2011-12-07 01:20:15.962"")

Categories : Java

QT UTC linux Clock skew detected. Your build may be incomplete
I think this error happens when your file times are newer than your system clock. make warns you that it may not be building everything correctly because of this. touching all your files should sort out the problem. One of the causes is an SCM system that preserves file times and is ahead of your system clock.

Categories : C++

inserting zeros between the elements of vector with high performance and speed ( preferred to use STL)
The reason it is slow is because the members of the vector are getting moved multiple times. Think about the members in the last row of your image. They all have to be moved once for every row of the image. It would be faster to create a whole new image, copying just the pixels you need from the original image and adding zeros where appropriate. Here's an example: void padColumns( std::vector<unsigned char> &old_image, size_t old_width, size_t new_width ) { size_t height = image.size() / old_width; assert(image.size() == old_width*height); std::vector<unsigned char> new_image(new_width * height); for (size_t row=0; row!=height; ++row) { std::copy( old_image.begin() + row*old_width, old_image.begin() + row*old_width + old_width,

Categories : Visual Studio 2010

Socket and ports setup for high-speed audio/video streaming
I think it is better to use an object mechanism and send data in an interleaved fashion. This mechanism may work faster than multiple port mechanism. eg: class Data { DataType, - (Adio/Video) Size, - (Size of the Data buffer) Data Buffer - (Data depends on the type) } 'DataType' and 'Size' always of constant size. At the client side take the 'DataType' and 'Size' and then read the specifed size of corresponding sent data(Adio/Video).

Categories : C#

TCP/UDP high-performance server under linux
Your basic approach is right. Start by studying the infamous C10K problem and how it was overcome. Once you understand the major bottlenecks in various implementations, you need to consider the following as part your design process : Minimise thread creation/deletion cycles. Always choose an "event-based" model over a blocking model. Basically the one-thread-per-request model is preferred for its simplicity of implementation. But it does NOT scale well with the number of concurrent requests. When designing systems required to support more than a few 1000 concurrent requests, one prefers the use of sockets over threads. The optimum number of "worker-threads" to instantiate depends upon : Load (number of concurrent requests) System (CPU, RAM) Since this is a very popular probl

Categories : Linux

Linux free shows high memory usage but top does not
Don't look at the "Mem" line, look at the one below it. The Linux kernel consumes as much memory as it can to provide the I/O cache (and other non-critical buffers, but the cache is going to be most of this usage). This memory is relinquished to processes when they request it. The "-/+ buffers/cache" line is showing you the adjusted values after the I/O cache is accounted for, that is, the amount of memory used by processes and the amount available to processes (in this case, 578MB used and 7411MB free). The difference of used memory between the "Mem" and "-/+ buffers/cache" line shows you how much is in use by the kernel for the purposes of caching: 7734MB - 578MB = 7156MB in the I/O cache. If processes need this memory, the kernel will simply shrink the size of the I/O cache.

Categories : Linux

compare client device clock with server clock exactly upto milliseconds
It looks like that they simply ignore problem of the network lag in their description. I notice their (vague) phrasing: (...) based on the determination that the matching [delta of time] parameter falls within the selected range (...) This could account for network lag variations. Over a large, busy network such as the Internet, it is not possible to bring the accuracy "down to the millisecond". Other network types (I'm thinking Token Ring or networks with very, very strict QoS policies) might allow this level of precision.

Categories : PHP

Javascript clock, change day in advance when clock hits hour
Because it was hard to understand your code, so I created a new counter: <html> <head> <script type="text/javascript"> var counterIntervalVar; var howManyDaysAhead = 0; var finishHours = 16; var finishMinutes = 0; var finishSeconds = 0; function ShowTimes() { var str = ""; var now = new Date();//Use current time as start time //Creating the target time var dayIncreasion = 1000 * 3600 * 24 * howManyDaysAhead; var targetDateInMilliSeconds = now.getTime(); var targetDate = new Date(targetDateInMilliSeconds + dayIncreasion); targetDate.setHours(finishHours); targetDate.setMinutes(finishMinutes); targetDate.setSeconds(finishSeconds); targetDateInMilliSeconds = targetDate.getTime(); //Calculate and show the

Categories : Javascript

How to speed up compilation time in linux
The rule of thumb is to use the number of processors+1. Hyper-Thready counts, so a quad core CPU with HT should have -j9 Setting the value too high is counter-productive, if you do want to speed up compile times consider ccache to cache compiled objects that do not change in each compilation, and distcc to distribute the compilation across several machines.

Categories : Linux

How to check CPU name, model, speed on Windows/Linux C?
For Windows, you'll want the GetSystemInfo function; Microsoft has an example. On Linux, /proc/cpuinfo is perfectly "safe", whatever that means, but there's already an answer to this question.

Categories : C

How can I measure CPU time and wall clock time on both Linux/Windows?
Use the clock method in time.h: clock_t start = clock(); /* Do stuffs */ clock_t end = clock(); float seconds = (float)(end - start) / CLOCKS_PER_SEC; Unfortunately, this method returns CPU time on Linux, but returns wall-clock time on Windows (thanks to commenters for this information).

Categories : C++

Uart 16c950 linux speed above B4000000 (4Mbps)
This page has a Linux kernel patch that adds direct exposure of the registers, so that ioctl() can be used to program custom baud rates. It's pretty old though, but might be useful for you.

Categories : C

Bulk convert log file date time format from 12 hour clock to 24 hour clock for mySQL database
If you want to do that on db side and you use MySql you can read it with STR_TO_DATE() and either use it as a datetime value INSERT INTO log (`Site_Name`, `number_of_clicks`, `date`, `Interaction_Type`) SELECT 'site1', 10, STR_TO_DATE('10/05/2013_2:00PM', '%d/%m/%Y_%l:%i%p'), 1; or UPDATE log SET date = STR_TO_DATE(str_date, '%d/%m/%Y_%l:%i%p'); assuming that date column is of type datetime, and str_date column contains string values in 12h format. or if for some reason you store it as VARCHAR and really need to format it as DD/MM/YYYY_14:00 then you can use DATE_FORMAT() DATE_FORMAT(STR_TO_DATE('10/05/2013_2:00PM', '%d/%m/%Y_%l:%i%p'), '%d/%m/%Y_%k:%i') which will produce | NEWDATE | -------------------- | 10/05/2013_14:00 | To update in-place UPDATE log SET

Categories : PHP

Azure Could Computing high availoability vs NEO4J high availability?
The short answer is probably yes. Windows Azure provide you infrastructure that allow you to build high availability system, it won't make any system high available by magic. As NEO4J is state-full, each node (with only one node Azure don't give you any SLA, you instance will be down) will need to share some state and the way to do it will be dependent on how NEO4J is working. So you will need to rely on NEO4J mechanism to do it. I don't know how NEO4J is working but you won't be able to skip designing an high available architecture around NEO4J using Windows Azure infra. Cloud may be a magic buzz word that can make things append on management level, but when we are on hard real world level Harry magic wand doesn't exist.

Categories : Neo4j

quicksand sorting price values low to high / high to low
val() gives you a string, so > and < comparisons are lexographical (not numeric). Try wrapping the values in parseInt() or parseFloat(). Make sure to add appropriate error handling as well.

Categories : Jquery

Different integer size usages
No. int.MaxValue is the largest value which can be represent by a 32 bit integer. If you want a larger value you use long which consumes 64 bits. Basically, the amount of memory an integer consumes has nothing to do with it's value. int small = 1 // translates to 0x00000001 while int big = int.MaxValue //translates to 0x7FFFFFFF They still consume that same 4 bytes of memory, they just have different values for the bits. The values in my code snippet are represented in hexadecimal, if you don't know how that translates into actual bits just check it out wikipedia.

Categories : C#

Varnish High DB Connections In High Traffic
Mostly spiking backend connections has little to do with your varnish configuration but alot to do with the cachability of your site. Are there cookies that prevents you from caching efficiently? You can chose to strip them or remove all but chosen ones, there are examples for both on the varnish site. Do a varnishstat and check your hit rates during peaks. Is it a good cache hitratio? Is it the same as during low load? If it's the same or higher in low load it's easy to work on improving it at any time. Do a varnishtop -i txurl to see what requests are the most frequently sent to backend servers. Maybe it's some URLs that are just not cached due to faulty headers? Maybe some pages can be cached longer? Maybe some parts of the pages can be cached with ESI? Make sure your varnish is not

Categories : Mysql

Force usages of method using new keyword c#
the only way, but it is a bad way class Program { static P1 p = new P1(); static void Main(string[] args) { var t = new P2(); p = t; ((P2)p).DoWork(); t.DoWork(); Console.ReadLine(); } }

Categories : C#

Obscure usages of C++ virtual inheritance
Okay so you are saying that you have: B + | v A + +----+----+ v v C D And all of these are non-virtual inheritance and then you have class E that virtualy inherits B and C also inherits it so a complete diagram would be: +-----------+B | + | | v v E A + + +---+---+----+----+ v v C D

Categories : C++

Regarding Usages matrix and rotate at a time
Yes, but you need to set it in the same property -webkit-transform: matrix(-1, 0, 0, 1, 0, 0) rotate(-180deg); transform: matrix(-1, 0, 0, 1, 0, 0) rotate(-180deg); You can not specify the same property 2 times, and expect that both are applied.

Categories : CSS

Find all usages of toString() method
Simply override the toString() method body in your Order class. Technically it is not possible to find all calls, because even system libraries call toString() in many places, like all kind of collections. Also you should pay attention to your templates (whatever GUI you are using.) So, you want to log the short printout, and debug the full (the original). Both are calling toString(). Then you could try to peek inside the calling stack trace to decide where is it called from. Use Thread.currentThread().getStackTrace() to access the current stack trace. Say, if any of the last 10 stacktrace elements is from you Log class, it is called for logging, then you can print the short printout. Otherwise do the full printout. Yes, it is good practice to move the different versions of toString()

Categories : Java

Common usages for chain of responsibility?
From the GoF: Known Uses Several class libraries use the Chain of Responsibility pattern to handle user events. They use different names for the Handler class, but the idea is the same: When the user clicks the mouse or presses a key, an event gets generated and passed along the chain. MacApp [App89] and ET++ [WGM88] call it "EventHandler," Symantec's TCL library [Sym93b] calls it "Bureaucrat," and NeXT's AppKit [Add94] uses the name "Responder." The Unidraw framework for graphical editors defines Command objects that encapsulate requests to Component and ComponentView objects [VL90]. Commands are requests in the sense that a component or component view may interpret a command to perform an operation. This corresponds to the "requests as objects" approach

Categories : Misc

netbeans find usages does not seem to scan xml files
Try with this plugin: JohnBaker FindUsages, Spring Support for Find usages. Stock "find usages" from Netbeans doesn't support Spring. There is also a generic Netbeans-Spring plugin. Personally I use Eclipse with STS.

Categories : Java

ReSharper: Find Usages of an optional parameter
With your cursor on the parameter, choose ReSharper | Inspect | Value Origin, or from the keyboard, Inspect This with Ctrl+Shift+Alt+A, then Value Origin. You will get an Inspection Results window with all the places that explicitly assign that parameter a value.

Categories : Visual Studio

How to rename a file in IntelliJ without finding usages?
No. IntelliJ must find the usages to rename them, otherwise you're just renaming the file, not refactoring. If you only want to rename the file, use the mv command from a terminal. You can also tell IntelliJ not to look in strings and text, which speeds things up somewhat, but is probably a bad idea in a javascript project (where almost everything is string or text). I use rename a lot, and on my codebase, which is pretty big, it only takes a couple of seconds. Maybe intellij needs more memory to operate in, so you could try increasing that.

Categories : Intellij Idea

async await usages for CPU computing vs IO operation?
Actually, you only get the second set of advantages in both cases. await doesn't start asynchronous execution of anything, it's simply a keyword to the compiler to generate code for handling completion, context etc. You can find a better explanation of this in '"Invoke the method with await"... ugh!' by Stephen Toub. It's up to the asynchronous method itself to decide how it achieves the asynchronous execution: Some methods will use a Task to run their code on a ThreadPool thread, Some will use some IO-completion mechanism. There is even a special ThreadPool for that, which you can use with Tasks with a custom TaskScheduler Some will wrap a TaskCompletionSource over another mechanism like events or callbacks. In every case, it is the specific implementation that releases the thread

Categories : C#

count of external symbol usages by shared library
you can use objdump and grep on each symbol, it should give you the number of times a symbol is referenced, here I call malloc twice from two different function: objdump -D test_prog | grep malloc 0000000000400928 <malloc@plt>: 400b91: e8 92 fd ff ff callq 400928 <malloc@plt> 400c9c: e8 87 fc ff ff callq 400928 <malloc@plt> Note: Ignore the first one it's the plt entry.

Categories : Linux

Visual studio - MVC Find usages of DisplayTemplate/EditorTemplate
There is one workaround/help. If you have Visual Studio 2013 and Web Essentials installed you can CTRL+click anywhere on the page and the menu like this pops up. If you click Inspect you can click on any element on page and then you cursor in Visual Studio moves to corresponding View/PartialView/DisplayTemplate/... Mads Kristensen post on Web essentials 2013

Categories : Asp Net Mvc

How to explain usages of square brackets ([]) operator in EL expressions
The [] will allow you to: Get a property, if the object is a bean (has getters and setters): ${car['type']} This will be equivalent to car.getType(); (or car.isType() if the type field is a boolean). Get a key's value, if the object is a Map: ${carMap['Volvo']} This will be equivalent to carMap.get('Volvo'); when carMap is a Map. Get an index, if the object is an array or List: ${cars[1]} This is equivalent to cars[1] if cars is an array or equivalent to cars.get(1) if cars is a List. More details/source: http://docs.oracle.com/javaee/6/tutorial/doc/bnahu.html Edit: Your question's expression (${owner['new']}) falls into the first case. In the petclinick app, the Owner class is a subclass of Person which is a subclass of BaseEntity. And BaseEntity has a method isNew() (so

Categories : Java

PHP Download file, limit max speed and calculate downloading speed
How about (re)adding that sleep(1); thing to the WHILE loop? From what I can see the script outputs the file almost all at once (as fast as it can) and there's nothing that pauses it so it can actually limit the download speed. That way you will know that each second you send just 64kbytes (or whatever) and even though you can't be sure that the user can in fact recieve this much data/second (whoa, so fast!), it could be a bit more precise than what you have in there now. Or am I getting this wrong?

Categories : PHP

When to use low < high or low + 1 < high for loop invariant
If your invariant is that the target must lie in low <= i <= high, then you use while (low < high); if your invariant is that the target must lie in low <= i < high then you use while (low + 1 < high). [Thanks to David Eisenstat for confirming this.]

Categories : Algorithm

How to find all the usages to instance variable object throughout call graph?
If I understand your question you are talking about interfaces. Lets say you have interface MyItf with several methods: public interface MyItf { public ToBeCalled getToBeCalled(); public void doXXX(); public void doYYY(); } By using interface ToBeCalled class must override all methods. public class ToBeCalled implements MyItf{ @Override public ToBeCalled getToBeCalled() { // TODO Auto-generated method stub return null; } @Override public void doXXX() { // TODO Auto-generated method stub } @Override public void doYYY() { // TODO Auto-generated method stub } } Other class: public class ToBeCalled2 implements MyItf{ @Override public ToBeCalled getToBeCalled() { // TODO Auto-generated method stub return null; } @Override public void doXXX() { // TO

Categories : Java

change update speed without changing loop speed?
To clarify on the concept of 'delta time', if you were to simply increment a counter without scaling it against real time, it would increment as fast as draw is called. However by scaling it, you are guaranteed a certain amount of frames per second. This way, you can always be sure that your animation is as slow or as fast as you want it. You can set your threshold to be for example 500 milliseconds (one frame every half a second), and so on. var counter = 0; function draw() { // deltaTime is how you plan on counting real seconds // against your frame ticks counter += deltaTime; ... // threshold would be your delay if (counter >= threshold) { hero.frames++; if (hero.frames >= 2) hero.frames = 0; counter = 0; } } setInterval( draw, 1000 / 5 );

Categories : Javascript



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