Search Results

Search found 23 results on 1 pages for 'flavio copes'.

Page 1/1 | 1 

  • Is this how dynamic language copes with dynamic requirement?

    - by Amumu
    The question is in the title. I want to have my thinking verified by experienced people. You can add more or disregard my opinion, but give me a reason. Here is an example requirement: Suppose you are required to implement a fighting game. Initially, the game only includes fighters, who can attack each other. Each fighter can punch, kick or block incoming attacks. Fighters can have various fighting styles: Karate, Judo, Kung Fu... That's it for the simple universe of the game. In an OO like Java, it can be implemented similar to this way: abstract class Fighter { int hp, attack; void punch(Fighter otherFighter); void kick(Fighter otherFighter); void block(Figther otherFighter); }; class KarateFighter extends Fighter { //...implementation...}; class JudoFighter extends Fighter { //...implementation... }; class KungFuFighter extends Fighter { //...implementation ... }; This is fine if the game stays like this forever. But, somehow the game designers decide to change the theme of the game: instead of a simple fighting game, the game evolves to become a RPG, in which characters can not only fight but perform other activities, i.e. the character can be a priest, an accountant, a scientist etc... At this point, to make it more generic, we have to change the structure of our original design: Fighter is not used to refer to a person anymore; it refers to a profession. The specialized classes of Fighter (KaraterFighter, JudoFighter, KungFuFighter) . Now we have to create a generic class named Person. However, to adapt this change, I have to change the method signatures of the original operations: class Person { int hp, attack; List<Profession> skillSet; }; abstract class Profession {}; class Fighter extends Profession { void punch(Person otherFighter); void kick(Person otherFighter); void block(Person otherFighter); }; class KarateFighter extends Fighter { //...implementation...}; class JudoFighter extends Fighter { //...implementation... }; class KungFuFighter extends Fighter { //...implementation ... }; class Accountant extends Profession { void calculateTax(Person p) { //...implementation...}; void calculateTax(Company c) { //...implementation...}; }; //... more professions... Here are the problems: To adapt to the method changes, I have to fix the places where the changed methods are called (refactoring). Every time a new requirement is introduced, the current structural design has to be broken to adapt the changes. This leads to the first problem. Rigid structure makes it hard for code reuse. A function can only accept the predefined types, but it cannot accept future unknown types. A written function is bound to its current universe and has no way to accommodate to the new types, without modifications or rewrite from scratch. I see Java has a lot of deprecated methods. OO is an extreme case because it has inheritance to add up the complexity, but in general for statically typed language, types are very strict. In contrast, a dynamic language can handle the above case as follow: ;;fighter1 punch fighter2 (defun perform-punch (fighter1 fighter2) ...implementation... ) ;;fighter1 kick fighter2 (defun perform-kick (fighter1 fighter2) ...implementation... ) ;;fighter1 blocks attacks from fighter2 (defun perform-block (fighter1 fighter2) ...implementation... ) fighter1 and fighter2 can be anything as long as it has the required data for calculation; or methods (duck typing). You don't have to change from the type Fighter to Person. In the case of Lisp, because Lisp only has a single data structure: list, it's even easier to adapt to changes. However, other dynamic languages can have similar behaviors as well. I work primarily with static languages (mainly C and Java, but working with Java was a long time ago). I started learning Lisp and some other dynamic languages this year. I can see how it helps improving my productivity.

    Read the article

  • Android: how do I switch between game scenes in a game? Any tutorials?

    - by Flavio
    I am trying to create a simple game using the Android SDK without using AndEngine (or any other game engine). I have plenty of experience designing games from the past, but I'm having lots of trouble trying to use the Android SDK to make my game. By far my biggest hurdle right now is switching between views. That is, for example, going from the menu to the first level, etc. I am using a traditional model I learned (I think it's called a scene stack or something?) in which you push the current scene onto a stack and the game's main loop runs the top item of the stack. This model seems non-trivial to implement in the Android SDK, mostly because Android seems to be picky about which thread instantiates which view. My issue is that I want the first level to show up when you press a button on the main menu, but when I instantiate the first level (the level class extends SurfaceView and implements SurfaceHolder.Callback) I get a runtime error complaining that the thread that runs the main menu can't instantiate this class. Something about calling Looper.prepare(). I figured at this point I was probably doing things wrong. I'm not sure how to specifically phrase my issue into a question, so maybe I should leave it as either 1) Does anybody know a good way (or the 'proper' way) to switch between scenes in an Android game? or 2) Are there any tutorials out there which show how to create a game that doesn't take place entirely in one scene? (I have googled for a while to no avail... maybe someone else knows of one?) Thanks!

    Read the article

  • cannot connect to Apache web server through hamachi

    - by Bruce copes
    we are running an apache web server in the office. Hamachi clients are installed on the server and on the other PC's. We can ping and browse each other but cannot view the web server through Hamachi. have disabled the firewalls on the server as well as on the PC's. I have added an apache program exception in the firewall on the server, but surely this is not needed if I disable the firewall? I would be really grateful if someone could help!

    Read the article

  • Postfix : error: unsupported dictionary type: mysql

    - by flavio.troja
    I've a problem w/ postfix problem: # tail -f /var/log/mail.err Aug 20 17:57:50 myserver postfix/smtpd[8243]: error: unsupported dictionary type: mysql Aug 20 17:57:50 myserver postfix/smtpd[8243]: error: unsupported dictionary type: mysql Aug 20 17:58:05 myserver postfix/smtpd[8244]: error: unsupported dictionary type: mysql Aug 20 17:58:05 myserver postfix/smtpd[8244]: error: unsupported dictionary type: mysql Aug 20 18:00:38 myserver postfix/smtpd[8277]: error: unsupported dictionary type: mysql Aug 20 18:00:38 myserver postfix/smtpd[8277]: error: unsupported dictionary type: mysql Aug 20 18:03:32 myserver postfix/smtpd[8320]: error: unsupported dictionary type: mysql Aug 20 18:03:32 myserver postfix/smtpd[8320]: error: unsupported dictionary type: mysql Aug 20 18:03:33 myserver postfix/trivial-rewrite[8322]: error: unsupported dictionary type: mysql Aug 20 18:03:33 myserver postfix/trivial-rewrite[8322]: error: unsupported dictionary type: mysql idea?

    Read the article

  • How to avoid Memory "Hard Fault/sec"

    - by Flavio Oliveira
    i've a problem on my windows 2008 server x64, and i cannot understand how can i solve it. i'm looking to Resource Monitor and see about 100 to 200 hard faults/sec. and generally the machine is slow. As i've readed a bit it is caused by a "memory Page" that is no longer available on physical memory and causes a io operations (disk) and it is a problem. The current hardware is a intel core2duo E8400 (3.0GHz) with 6GB RAM on a Windows Server Web 64-bit. Actually the machine have about 2GB Ram used what having 4Gb available to use, Why is the machine requires that high level of Disk operations? what can i do to increase the performance? Im experiencing a memory issues? what should be my starting point?

    Read the article

  • Robotium - Write to file in eclipse workspace or computer file system

    - by Flavio Capaccio
    I'm running some tests using Robotium on an Android application that interacts with a web-portal. I'd like to save some information to file; for example I need to save the id of the username I created from the app and I want to make it read from Selenium to run tests on web-portal to verify a webpage for that user has been created. Is it possible? Could someone suggest me a solution or a work-around? This is an example of code, but it doesn't work (I want to write to a file for example on c:\myworkspace\filename.txt a string): public void test_write_file(){ if(!solo.searchText("HOME")){ signIn("39777555333", VALID_PASSWORD); } try { String content = "This is the content to write into file"; File file = new File("filename.txt"); // if file doesnt exists, then create it if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write(content); bw.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } assertTrue(solo.searchText("HOME")); }

    Read the article

  • C#: How to run NUnit from my code

    - by Flavio
    Hello, I'd like to use NUnit to run unit tests in my plug-in, but it needs to be run in the context of my application. To solve this, I was trying to develop a plug-in that runs NUnit, which in turn will execute my tests in the application's context. I didn't find a specific documentation on this subject so I dug a piece of information here and there and I came out with the following piece of code (which is similar to one I found here in StackOverflow): SimpleTestRunner runner = new SimpleTestRunner(); TestPackage package = new TestPackage( "Test" ); string loc = Assembly.GetExecutingAssembly().Location package.Assemblies.Add( loc ); if( runner.Load(package) ) { TestResult result = runner.Run( new NullListener() ); } The result variable says "has no TestFixture" although I know for sure it is there. In fact my test file contains two test. Using another approach I found, which is summarized by the following code: TestSuiteBuilder builder = new TestSuiteBuilder(); TestSuite testSuite = builder.Build( package ); // Run tests TestResult result = testSuite.Run( new NullListener(), NUnit.Core.TestFilter.Empty ); I saw nunit data structures with only 1 test and I had the same error. For sake of completeness, I am using the latest version of nunit, which is 2.5.5.10112. Does anyone know what I'm missing? A sample code would be appreciated. thanks

    Read the article

  • WNetAddConnection2 from a Windows Service

    - by Flavio
    I'm trying to connect to a remote password protected shared folder from a Windows service, which runs as LocalSystem account. It seems that the LocalSystem account is unable to directly access password-protected network shares using WNetAddConnection2() or similar calls. Can anyone confirm this? I've read that impersonating an administrator user might be the way to go. I've tried using LogonUser() and ImpersonateLoggedOnUser() before WNetAddConnection2(), it appears that the mount of the network path succeeds, but then actual accesses (e.g. enumerating of files in remote folder) fail. Any ideas? Thanks.

    Read the article

  • C# Changing class method at run-time

    - by Flavio
    Hi, I need to extend the behavior of an instance, but I don't have access to the original source code of that instance. For example: /* I don't have the source code for this class, only the runtime instance */ Class AB { public void execute(); } in my code I would to intercept every call to execute, compute some sutff and then call the original execute, something like /* This is how I would like to modify the method invokation */ SomeType m_OrgExecute; { AB a = new AB(); m_OrgExecute = GetByReflection( a.execute ); a.execute = MyExecute; } void MyExecute() { System.Console.Writeln( "In MyExecute" ); m_OrgExecute(); } Is that possible? Does anyone have a solution for this problem?

    Read the article

  • How do I test if a variable is a number in bash?

    - by Flávio Amieiro
    I just can't figure out how do I make sure an argument passed to my script is a number or not. All I want to do is something like this: test *isnumber* $1 && VAR=$1 || echo "need a number" Any help? UPDATE: I managed (whit Charles' help) to do it, but I'm not yet sure it's the best way to do that (even though it worked on my tests). This is how it ended up: [[ $1 =~ "^[0-9]+$" ]] && echo "numero" && exit 0 || echo "nao numero" && exit 1

    Read the article

  • Force CL-Lex to read whole word

    - by Flávio Cruz
    I'm using CL-Lex to implement a lexer (as input for CL-YACC) and my language has several keywords such as "let" and "in". However, while the lexer recognizes such keywords, it does too much. When it finds words such as "init", it returns the first token as IN, while it should return a "CONST" token for the "init" word. This is a simple version of the lexer: (define-string-lexer lexer (...) ("in" (return (values :in $@))) ("[a-z]([a-z]|[A-Z]|\_)" (return (values :const $@)))) How do I force the lexer to fully read the whole word until some whitespace appears?

    Read the article

  • Is there any software or hardware which lets you stop, slow down, speed up or even reverse time?

    - by tjrobinson
    Obviously I'm talking about time in terms of the PC clock rather than real time. We were testing an application we've developed at work by setting the clock forward and back to simulate different scenarios and I started thinking how useful it would be if you could adjust the rate(?) of the system clock with finer control. So you could make a minute pass in a second or a day pass in 30 seconds and watch how the program you're developing copes with changes in date and time. I'd be interested to hear if anyone knows of any software or hardware which can let you do some or all of the above.

    Read the article

  • Iterative Conversion

    - by stuart ramage
    Question Received: I am toying with the idea of migrating the current information first and the remainder of the history at a later date. I have heard that the conversion tool copes with this, but haven't found any information on how it does. Answer: The Toolkit will support iterative conversions as long as the original master data key tables (the CK_* tables) are not cleared down from Staging (the already converted Transactional Data would need to be cleared down) and the Production instance being migrated into is actually Production (we have migrated into a pre-prod instance in the past and then unloaded this and loaded it into the real PROD instance, but this will not work for your situation. You need to be migrating directly into your intended environment). In this case the migration tool will still know all about the original keys and the generated keys for the primary objects (Account, SA, etc.) and as such it will be able to link the data converted as part of a second pass onto these entities. It should be noted that this may result in the original opening balances potentially being displayed with an incorrect value (if we are talking about Financial Transactions) and also that care will have to be taken to ensure that all related objects are aligned (eg. A Bill must have a set to bill segments, meter reads and a financial transactions, and these entities cannot exist independantly). It should also be noted that subsequent runs of the conversion tool would need to be 'trimmed' to ensure that they are only doing work on the objects affected. You would not want to revalidate and migrate all Person, Account, SA, SA/SP, SP and Premise details since this information has already been processed, but you would definitely want to run the affected transactional record validation and keygen processes. There is no real "hard-and-fast" rule around this processing since is it specific to each implmentations needs, but the majority of the effort required should be detailed in the Conversion Tool section of the online help (under Adminstration/ The Conversion Tool). The major rule is to ensure that you only run the steps and validation/keygen steps that you need and do not do a complete rerun for your subsequent conversion.

    Read the article

  • Visual Studio 2010 Service Pack 1 Released

    - by krislankford
    The VS 2010 SP 1 release was simultaneous to the release of TFS 2010 SP1 and includes support for the Project Server Integration Feature Pack and updates to .NET Framework 4.0. The complete Visual Studio SP1 list including Test and Lab Manager: http://support.microsoft.com/kb/983509 The release addresses some of the most requested features from customers of Visual Studio 2010 like better help support IntelliTrace support for 64bit and SharePoint Silverlight 4 Tools in the box unit testing support on .NET 3.5 a new performance wizard for Silverlight Another major addition is the announcement of Unlimited Load Testing for Visual Studio 2010 Ultimate with MSDN Subscribers! The benefits of Visual Studio 2010 Load Test Feature Pack and useful links: Improved Overall Software Quality through Early Lifecycle Performance Testing: Lets you stress test your application early and throughout its development lifecycle with realistically modeled simulated load. By integrating performance validations early into your applications, you can ensure that your solution copes with real-world demands and behaves in a predictable manner, effectively increasing overall software quality. Higher Productivity and Reduced TCO with the Ability to Scale without Incremental Costs: Development teams no longer have to purchase Visual Studio Load Test Virtual User Pack 2010. Download the Visual Studio 2010 Load Test Feature Pack Deployment Guide Get started with stress and performance testing with Visual Studio 2010 Ultimate: Quality Solutions Best Practice: Enabling Performance and Stress Testing throughout the Application Lifecycle Hands-On-Lab: Introduction to Load Testing with ASP.NET Profile in Visual Studio 2010 How-Do-I videos: Use ASP.NET Profiler in Load Tests Use Network Emulation in Load Tests VHD/VPC walkthrough: Getting Started with Load and Performance Testing Best Practice guidance: Visual Studio Performance Testing Quick Reference Guide

    Read the article

  • SQL searching table fields with LIKE

    - by Tom Gullen
    Given your data stored somewhere in a database: Hello my name is Tom I like dinosaurs to talk about SQL. SQL is amazing. I really like SQL. We want to implement a site search, allowing visitors to enter terms and return relating records. A user might search for: Dinosaurs And the SQL: WHERE articleBody LIKE '%Dinosaurs%' Copes fine with returning the correct set of records. How would we cope however, if a user mispells dinosaurs? IE: Dinosores (Poor sore dino). How can we search allowing for error in spelling? We can associate common misspellings we see in search with the correct spelling, and then search on the original terms + corrected term, but this is time consuming to maintain. Any way programatically?

    Read the article

  • (solved) `ssh foo "<command/>"` not loading remote aliases?

    - by TomRoche
    summary: Why does this fail $ ssh foo 'R --version | head -n 1' bash: R: command not found but this succeeds $ ssh foo 'grep -nHe 'bashrc' ~/.bash_profile' /home/me/.bash_profile:3:# source the users .bashrc if it exists /home/me/.bash_profile:4:if [ -f "${HOME}/.bashrc" ] ; then /home/me/.bash_profile:5: source "${HOME}/.bashrc" $ ssh foo 'grep -nHe "\WR\W" ~/.bashrc' /home/me/.bashrc:118:alias R='/share/linux86_64/bin/R' $ ssh foo '/share/linux86_64/bin/R --version | head -n 1' R version 2.14.1 (2011-12-22) ? details: I am a (rootless) user on 2 clusters. One uses environment modules, so any given server on that cluster can provide (via module add) pretty much the same resources. The other cluster, on which I must also unfortunately work, has servers managed individually, so I get in the habit of doing, e.g., EXEC_NAME='whatever' for S in 'foo' 'bar' 'baz' ; do ssh ${SERVER} "${EXEC_NAME} --version" done This works fine for packages installed normally/consistently, but often (for reasons unknown to me) packages are not: e.g. (compare alias below to alias above), $ ssh bar 'R --version | head -n 1' bash: R: command not found $ ssh bar 'grep -nHe 'bashrc' ~/.bash_profile' /home/me/.bash_profile:3:# source the users .bashrc if it exists /home/me/.bash_profile:4:if [ -f "${HOME}/.bashrc" ] ; then /home/me/.bash_profile:5: source "${HOME}/.bashrc" $ ssh bar 'grep -nHe "\WR\W" ~/.bashrc' /home/me/.bashrc:118:alias R='/share/linux/bin/R' $ ssh bar '/share/linux86_64/bin/R --version | head -n 1' R version 2.14.1 (2011-12-22) Using aliases copes well with these install differences when I interactively shell into the server, but fails when I try to script ssh commands (as above); i.e., # interactively $ ssh foo ... foo> R --version calls my alias for R on remote host=foo, but # scripting $ ssh foo 'R --version' doesn't. What do I need to do to make ssh foo "<command/>" load my aliases on the remote host?

    Read the article

  • How can I log and retrieve error messages from a client-side desktop app?

    - by KeyboardMonkey
    Update: The service-based answers below are most likely the way to go, I am also curious to see if there are any out-the-box solutions anyone has tried in the field. Our system uses a client-server architecture, and with more clients using it I'm thinking of better ways to log client application errors, and get them sent to us. Currently we just show a simple error message, with a button that preps an email (with the default system email client) and the clients send this on to our support address. This contains extra info like the stack trace. We also tried saving errors to a network share in the company, but I'm not too keen on that archaic solution either. Now there are only two businesses that refer to clients as users, and I'm sure some of ours support both lifestyles, as they just ignore the email button, and sends a full screen-shot wrapped nicely in a word document. Some factors I'm thinking of include A solution to log errors, like the contrived one above, A robust solution; Logging to a SQL database won't work; if that fails too, then what? Is at least semi-automated, preferably to the point where the logs reach my side. It copes with load, our client base is growing and the current solution, and our inboxes, won't hold up. Minimise installing extra 3rd party components on clients, I want to keep the SPOF to a min. I'd love to hear about any experience or suggestions you have on how I can implement such a solution. System Details It's a Microsoft .Net 2 based system with a SQL backend. Some users work remotely over the net, so network shares aren't always available (unless they VPN, which is awesomely slow at any rate). We have users across different companies, their DB's are hosted on-site. We have remote access to 90% of them.

    Read the article

  • BizTalk: namespaces

    - by Leonid Ganeline
    BizTalk team did a good job hiding the .NET guts from developers. Developers are working with editors and hardly with .NET code. The Orchestration editor, the Mapper, the Schema editor, the Pipeline editor, all these editors hide what is going on with artifacts created and deployed. Working with the BizTalk artifacts year after year brings us some knowledge which could help to understand more about the .NET guts. I would like to highlight the .NET namespaces. What they are, how they influence our everyday tasks in the BizTalk application development. What is it? Most of the BizTalk artifacts are compiled into the NET classes. Not all of them… but I will show you later. Classes are placed inside the namespaces. I will not describe here why we need namespaces and what is it. I assume you all know about it more then me. Here I would like to emphasize that almost each BizTalk artifact is implemented as a .NET class within a .NET namespace. Where to see the namespaces in development? The namespaces are inconsistently spread across the artifact parameters. Let’s start with namespace placement in development. Then we go with namespaces in deployment and operations. I am using pictures from the BizTalk Server 2013 Beta and the Visual Studio 2012 but there was no changes regarding the namespaces starting from the BizTalk 2006. Default namespace When a new BizTalk project is created, the default namespace is set up the same as a name of a project. This namespace would be used for all new BizTalk artifacts added to this project. Orchestrations When we select a green or a red markers (the Begin and End orchestration shapes) we will see the orchestration Properties window. We also can click anywhere on the space between Port Surfaces to see this window.   Schemas The only way to see the NET namespace for map is selecting the schema file name into the Solution Explorer. Notes: We can also see the Type Name parameter. It is a name of the correspondent .NET class. We can also see the Fully Qualified Name parameter. We cannot see the schema namespace when selecting any node on the schema editor surface. Only selecting a schema file name gives us a namespace parameter. If we select a <Schema> node we can get the Target Namespace parameter of the schema. This is NOT the .NET namespace! It is an XML namespace. See this XML namespace inside the XML schema, it is shown as a special targetNamespace attribute Here this XML namespace appears inside the XML document itself. It is shown as a special xmlns attribute.   Maps It is similar to the schemas. The only way to see the NET namespace for map is selecting a map file name into the Solution Explorer. Pipelines It is similar to the schemas. The only way to see the NET namespace for pipeline is selecting a pipeline file name into the Solution Explorer. z Ports, Policies and Tracking Profiles The Send and Receive Ports, the Policies and the BAM Tracking Profiles do not create the .NET classes and they do not have the associated .NET namespaces. How to copy artifacts? Since the new versions of the BizTalk Server are going to production I am spending more and more time redesigning and refactoring the BizTalk applications. It is good to know how the refactoring process copes with the .NET namespaces. Let see what is going on with the namespaces when we copy the artifacts from one project to another. Here is an example: I am going to group the artifacts under the project folders. So, I have created a Group folder, have run the Add / Existing Item.. command and have chosen all artifacts in the project root. The artifact copies were created in the Group folder: What was happened with the namespaces of the artifacts? As you can see, the folder name, the “Group”, was added to the namespace. It is great! When I added a folder, I have added one more level in the name hierarchy and the namespace change just reflexes this hierarchy change.  The same namespace adjustment happens when we copy the BizTalk artifacts between the projects. But there is an issue with the namespace of an orchestration. It was not changed. The namespaces of the schemas, maps, pipelines are changed but not the orchestration namespace. I have to change the orchestration namespace manually. Now another example: I am creating a new Project folder and moving the artifacts there from the project root by drag and drop. We will mention the artifact namespaces are not changed. Another example: I am copying the artifacts from the project root by (drag and drop) + Ctrl. We will mention the artifact namespaces are changed. It works exactly as it was with the Add / Existing Item.. command. Conclusion: The namespace parameter is put inconsistently in different places for different artifacts Moving artifacts changes the namespaces of the schemas, maps, pipelines but not the orchestrations.

    Read the article

  • Odd optimization problem under MSVC

    - by Goz
    I've seen this blog: http://igoro.com/archive/gallery-of-processor-cache-effects/ The "weirdness" in part 7 is what caught my interest. My first thought was "Thats just C# being weird". Its not I wrote the following C++ code. volatile int* p = (volatile int*)_aligned_malloc( sizeof( int ) * 8, 64 ); memset( (void*)p, 0, sizeof( int ) * 8 ); double dStart = t.GetTime(); for (int i = 0; i < 200000000; i++) { //p[0]++;p[1]++;p[2]++;p[3]++; // Option 1 //p[0]++;p[2]++;p[4]++;p[6]++; // Option 2 p[0]++;p[2]++; // Option 3 } double dTime = t.GetTime() - dStart; The timing I get on my 2.4 Ghz Core 2 Quad go as follows: Option 1 = ~8 cycles per loop. Option 2 = ~4 cycles per loop. Option 3 = ~6 cycles per loop. Now This is confusing. My reasoning behind the difference comes down to the cache write latency (3 cycles) on my chip and an assumption that the cache has a 128-bit write port (This is pure guess work on my part). On that basis in Option 1: It will increment p[0] (1 cycle) then increment p[2] (1 cycle) then it has to wait 1 cycle (for cache) then p[1] (1 cycle) then wait 1 cycle (for cache) then p[3] (1 cycle). Finally 2 cycles for increment and jump (Though its usually implemented as decrement and jump). This gives a total of 8 cycles. In Option 2: It can increment p[0] and p[4] in one cycle then increment p[2] and p[6] in another cycle. Then 2 cycles for subtract and jump. No waits needed on cache. Total 4 cycles. In option 3: It can increment p[0] then has to wait 2 cycles then increment p[2] then subtract and jump. The problem is if you set case 3 to increment p[0] and p[4] it STILL takes 6 cycles (which kinda blows my 128-bit read/write port out of the water). So ... can anyone tell me what the hell is going on here? Why DOES case 3 take longer? Also I'd love to know what I've got wrong in my thinking above, as i obviously have something wrong! Any ideas would be much appreciated! :) It'd also be interesting to see how GCC or any other compiler copes with it as well! Edit: Jerry Coffin's idea gave me some thoughts. I've done some more tests (on a different machine so forgive the change in timings) with and without nops and with different counts of nops case 2 - 0.46 00401ABD jne (401AB0h) 0 nops - 0.68 00401AB7 jne (401AB0h) 1 nop - 0.61 00401AB8 jne (401AB0h) 2 nops - 0.636 00401AB9 jne (401AB0h) 3 nops - 0.632 00401ABA jne (401AB0h) 4 nops - 0.66 00401ABB jne (401AB0h) 5 nops - 0.52 00401ABC jne (401AB0h) 6 nops - 0.46 00401ABD jne (401AB0h) 7 nops - 0.46 00401ABE jne (401AB0h) 8 nops - 0.46 00401ABF jne (401AB0h) 9 nops - 0.55 00401AC0 jne (401AB0h) I've included the jump statetements so you can see that the source and destination are in one cache line. You can also see that we start to get a difference when we are 13 bytes or more apart. Until we hit 16 ... then it all goes wrong. So Jerry isn't right (though his suggestion DOES help a bit), however something IS going on. I'm more and more intrigued to try and figure out what it is now. It does appear to be more some sort of memory alignment oddity rather than some sort of instruction throughput oddity. Anyone want to explain this for an inquisitive mind? :D Edit 3: Interjay has a point on the unrolling that blows the previous edit out of the water. With an unrolled loop the performance does not improve. You need to add a nop in to make the gap between jump source and destination the same as for my good nop count above. Performance still sucks. Its interesting that I need 6 nops to improve performance though. I wonder how many nops the processor can issue per cycle? If its 3 then that account for the cache write latency ... But, if thats it, why is the latency occurring? Curiouser and curiouser ...

    Read the article

1