background preloader

Optimization

Facebook Twitter

Fluxus. What load balancing software do you use ? Regular Expression Matching Can Be Simple And Fast. Russ Coxrsc@swtch.com January 2007 Introduction This is a tale of two approaches to regular expression matching. One of them is in widespread use in the standard interpreters for many languages, including Perl. The other is used only in a few places, notably most implementations of awk and grep. Let's use superscripts to denote string repetition, so that a? Notice that Perl requires over sixty seconds to match a 29-character string. It may be hard to believe the graphs: perhaps you've used Perl, and it never seemed like regular expression matching was particularly slow.

Historically, regular expressions are one of computer science's shining examples of how using good theory leads to good programs. Today, regular expressions have also become a shining example of how ignoring good theory leads to bad programs. This article reviews the good theory: regular expressions, finite automata, and a regular expression search algorithm invented by Ken Thompson in the mid-1960s. Regular Expressions. Talks /* javascript */ ecmascript » Blog Archive » Logical AND (&&) and Logical OR (||) in Javascript. Logical AND (represented as &&) and logical OR (represented as ||) are interesting critters in Javascript.

You can get along for weeks, months, or even years without ever knowing the subtle nuance I'm going to discuss in this post. If your background is... well, pretty much any other language on the planet (and especially a compiled one), then chances are you've used Logical AND/OR like this: if (x > 5 && x < 10){ // x is greater than 5 and less than 10} But I'm guessing you probably haven't ever used it like this: function sayHi(name){ name = name || 'Whoever you are'; alert('Hi there ' + name);} What's going on here?

Read on to learn more. In Javascript, Logical AND/OR don't always return true or false. Instead, when evaluating Logical AND/OR, Javascript will return one of the operands as the result of the operation. Here are the two basic rules: For Logical AND (&&): Javascript returns the first value that is "false-like", or the last value, if no values are "false-like". Actually work. C++ Code Optimizations. Speed/PerformanceTips. This page is devoted to various tips and tricks that help improve the performance of your Python programs. Wherever the information comes from someone else, I've tried to identify the source. Python has changed in some significant ways since I first wrote my "fast python" page in about 1996, which means that some of the orderings will have changed. I migrated it to the Python wiki in hopes others will help maintain it.

You should always test these tips with your application and the specific version of the Python implementation you intend to use and not just blindly accept that one method is faster than another. Also new since this was originally written are packages like Cython, Pyrex, Psyco, Weave, Shed Skin and PyInline, which can dramatically improve your application's performance by making it easier to push performance-critical code into C or machine language. Other Versions Russian: Overview: Optimize what needs optimizing Sorting use. How to install initng on gentoo a faster init for linux.