Dec 10, 2019 19:31
+ it's definitely due to the alignment of instructions. This changes everything. The prefetch works as expected and is not the (main) reason for this behavior it seems.
Dec 10, 2019 19:28
Tried every multiple of 8bit alignment. It has a period of 128bit, so repeats the pattern as seen in the graphic
Dec 10, 2019 19:27
Dec 10, 2019 19:26
So I looked into it a bit more. Last week was very stressful, sorry for my late reply and thank you so much for looking into it yourself!

Anyway, I played around with the overall alignment of the function code. (This is only executed once, so those nops shouldn't affect the timing at all
Nov 30, 2019 20:11
@old_timer Deliberately pushing an even number of words doesn't significantly change the outcome.
Nov 30, 2019 20:11
@old_timer Thank you so much for your effort! Sorry, was night time over here. Holds true for different r1. The padding nops are indeed part of the function body, so have to be executed. They are only executed once though (as opposed to the rest which traverses a vast number of loops) so I'd say the nop influence in the prologue can be neglected.
Nov 30, 2019 20:11
@PeterCordes Aligning that label with .p2align 4 makes it perform worse (see edit) I think we can now agree with prefetch issues due to code size and alignment. Still very weird behavior.
Nov 30, 2019 20:11
@old_timer check my edits, padding definitely seems to change something! For a weird reason, adding padding also changes the run time of the non-padded function. Plus if I run each one on their own, they both perform well!
Nov 30, 2019 20:11
Yeah, they are using speculative instruction fetches. Thing is, both of these functions reside in flash and aren't loaded into RAM. Still, there is a discrepancy. For what it's worth, the same thing can be observed with equal machine code functions residing in two different RAM regions, but that's another thing for later ...
Nov 30, 2019 20:11
Thanks. Will keep that in mind for next time. According to the disassembly, there is no prologue generated anyway and the epilogue branch is redundant, doesn't do anything though (as noted in the code comment)
 

Python

Room rules: sopython.com/chatroom Code formatting guide: tinyu...
May 17, 2013 12:13
Thanks, I will look into it! @Inhale.Py
May 17, 2013 12:09
I route HTTPS requests (port 443) to a port that is listened to by a python server/socket - can I somehow access the "target" IP of the HTTPS request? @Inhale.Py
May 17, 2013 11:45
I'm a total beginner in Python so please bear with me. Following situation: IPTables -> HTTPS request listened to by Python socket. Can I somehow get the original HTTPS request's IP/Domain?
 
Feb 20, 2012 14:34
Feb 20, 2012 14:33
To convert a human readable date to unix time, you can for example use a program like this
Feb 20, 2012 14:33
This will return exactly February 20 2012 13:04:31
Feb 20, 2012 14:32
+ (NSDate *)date
{
return [NSDate dateWithTimeIntervalSince1970:1329743071];
}
Feb 20, 2012 14:31
For example to return February 20 2012, you use this method:
Feb 19, 2012 19:09
Seems like a healthy mix of C and Objective C ;)
Feb 19, 2012 19:08
This returns the date in 60 seconds (every time, the method is called)
Feb 19, 2012 19:08
+ (NSDate *)date
{
return [NSDate dateWithTimeIntervalSince1970:time(NULL)+60];
}
Feb 19, 2012 19:07
If you want to get a 'progressive' (one, that is actually changing), it would be best to use something like this:
Feb 19, 2012 18:54
As soon as you import this category, [NSDate date]; will return '1970-01-01 00:00:00 +0000'
Feb 19, 2012 18:51
MockDate.h:
#import <Foundation/Foundation.h>

@interface NSDate (MockDate)

+ (NSDate *)date;

@end

Mockdate.m:
#import "MockDate.h"

@implementation NSDate (MockDate)

+ (NSDate *)date
{
return [NSDate dateWithTimeIntervalSince1970:0];
}

@end
Feb 19, 2012 18:47
With the implementation I posted earlier, you can set your [NSDate date]; to every value you want
Feb 19, 2012 18:34
<code>+ (NSDate *)date
{
return [NSDate dateWithTimeIntervalSince1970:0];
}</code> This, well, returns the date of 1970 (beginning of UNIX-Time). To change the test date, just modify the return-statement. (If I have understood your question correctly)
Feb 19, 2012 18:34
You only have to swap it out in the declaration (i.e. in the category) and it applies to all your implementations.
Feb 19, 2012 18:34
Here is another possible solution: Create a NSDate category, that overrides + (NSDate *)date with your proposed test-date and only #import this category for testing purposes. Taking this approach, you don't have to change anything in your main code.
Feb 19, 2012 18:34
Seems dirty, but you could just use your own [NSDate mockDate] everywhere, and for test cases just return your own date. In all other cases it should simply return [NSDate date]