Sandbox archive

This post exists purely to house answers formerly attached to the formatting sandbox. You can safely ignore it.

On my E8200 box this doesn't occur, but on my Atom N450 netbook (both running OpenSuse 11.2), whenever I read the CPU's TSC, the returned value is mod 10 == 0, i. e. it is without remainder divisible by 10. I'm using the RDTSC value for measuring times that interesting pieces of code take, but for the purpose of demonstration I've made up this little program:

        .text
.global _start

_start: xorl    %ebx,%ebx
xorl    %ecx,%ecx
xorl    %r14d,%r14d
movb    $10,%cl loop: xchgq %rcx,%r15 # save to reg cpuid rdtsc shlq$32,%rdx
xorq    %rax,%rdx          # full 64 but of RDTSC
movq    %r14,%r13          # save the old value
movq    %rdx,%r14          # copy current
movq    %r14,%rsi          #  argv[1] of printf()
subq    %r13,%rdx          #  argv[2] (delta)
leaq    format(%rip),%rdi  #  argv[0]
xorl    %eax,%eax          #  no stack varargs
call    printf
xchgq   %rcx,%r15
loop    loop

0:      xorl    %eax,%eax
movb    $0x3c,%al syscall .size _start, .-_start .data format: .asciz "rdtsc: %#018llx = %1$llu -- delta: %llu\n"


(I usually use my own routines for converting, but to prevent readers from suggesting that the error might be there, I'm just using printf() here.)

With the above code, the output is (for example):

rdtsc: 0x000b88ef933ffd06 = 3246787292822790 -- delta: 3246787292822790
rdtsc: 0x000b88ef9342fcf4 = 3246787293019380 -- delta: 196590
rdtsc: 0x000b88ef93435dca = 3246787293044170 -- delta: 24790
rdtsc: 0x000b88ef9343b43c = 3246787293066300 -- delta: 22130
rdtsc: 0x000b88ef93440c34 = 3246787293088820 -- delta: 22520
rdtsc: 0x000b88ef9344604e = 3246787293110350 -- delta: 21530
rdtsc: 0x000b88ef9344b4d6 = 3246787293131990 -- delta: 21640
rdtsc: 0x000b88ef9345085a = 3246787293153370 -- delta: 21380
rdtsc: 0x000b88ef93455d96 = 3246787293175190 -- delta: 21820
rdtsc: 0x000b88ef9345b16a = 3246787293196650 -- delta: 21460


As can be easily seen, the delta varies in reasonable amounts. But conspicuous (not to say conspired ;-) is that the least significant decimal digit is always 0.

I've observed this phenomenon for more than two years now, and stackoverflow.com is not the first address where I make this issue public. But nowhere I got a reasonable answer yet. The ideas we (me and other people out there) came up with, are that

• the TSC is incremented only every 10th cycle, but then by 10, or
• the TSC is internally updated correctly, but reflected to the outside only every 10th cycle, or
• the TSC is incremented by 10 each cycle.

None of these points really make sense, however. I should have actually run a program like that on the E8200 (which is currently out of order) to see if the order of magnitude of the deltas is the same or only a tenth of those in the above output. (Any volunteers?)

Googling didn't help, Intel's manuals did neither.

When discussing with other people, there was no-one else who experienced the same behaviour. If it had to do with the kernel, then at least 3 versions were affected, but then... what does the kernel have to do with it?

I've also had the netbook in service, and it came back with a new motherboard — implied a new CPU, so at least two individual entities of N450 must be affected.

I've also took measures against clock frequency changes (and no matter what frequency I fixed the clock to, the values varied only in the expected range (the same as shown)), and switched off HT, though these should actually help to get some other least significand digits, rather than preventing them. But just to be sure.

Well, if anyone wants to run the program on their machine, the command line is (provided you save the source in a file rdtsc.s):

as rdtsc.s -o rdtsc.o
ld --dynamic-linker=/lib64/ld-linux-x86-64.so.2 rdtsc.o -L /lib64 -l c -o rdtsc


In order to build it with the gcc frontend, i. e.

gcc -l c rdtsc.s -o rdtsc


you must add (or replace the _start: label with) a main: label and make it global.

• Cool, always wanted to try it myself – Yatharth Agarwal Sep 17 '12 at 16:27

And this is a...

Spoiler!

Multi-line spoiler:

Spoiler line 1 (note the two spaces at the end of this line and the next)

Spoiler line 2

testing slashes escaping in backticks code in answers \, \\ and \a, \\a

• I can show \ without using double slash \\ – hims056 Oct 12 '12 at 5:09
• @hims056 the things I discovered is in meta.stackexchange.com/a/150161/179635 – ajax333221 Oct 12 '12 at 5:15
• testing slashes escaping in backticks code in comments , \ and \a, \\a – ajax333221 Oct 12 '12 at 5:21
• \ will display , \\ will display \, \\hi will display \\hi, \\\hi will display \\\hi – ajax333221 Oct 12 '12 at 5:26

Code:

this is
a test


Result:

this is a test

Testing markdown. Thanks Arjan

unfunny.

unfunny.

Oh gee look, you can so too underline in Stack Exchange sites:

̲u̲n̲d̲e̲r̲l̲i̲n̲e̲ ̲

̳u̳n̳f̳u̳n̳n̳y̳

̳u̳n̳d̳e̳r̳l̳i̳n̳e̳ ̳

  ̲̅M̲̅C̲̅M̲̅X̲̅C̲̅I̲̅X̲̅ ̲̅

̲̅m̲̅c̲̅m̲̅x̲̅c̲̅i̲̅x̲̅ ̲̅

• Need some help? – Arjan Mar 11 '11 at 9:56
• @Arjan Sure... Looking in the markdown manual I wanted to see what the checkmark did. Also I want to post linebreaks in comments – mplungjan Mar 11 '11 at 10:02
• The [checkmark] is a named reference, just like [1] which is inserted when using the Insert Image button (which is to be preferred, to ensure that the image is uploaded to the Stack Exchange Pro account at Imgur, which does not expire images). So, you need [checkmark]: http://w3.org/Icons/valid-xhtml10 as well, as shown in that example. And you could rename checkmark to anything you like, as long as it's unique. Comments do not allow for newlines. (Though hitting Shift-Return might get you a newline while editing. It won't display though.) – Arjan Mar 11 '11 at 10:07
• See the "Basic Links" section in the help for many ways to define URLs for links, which also applies to images. Like the following would work too: ![valid XHTML checkmark](http://w3.org/Icons/valid-xhtml10) – Arjan Mar 11 '11 at 10:13
• Still not funny? ;-) Enjoy! – Arjan Mar 11 '11 at 10:16
• M̲M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅M̲̅atress springs! – Ry- Mar 20 '12 at 23:17
• ​​​​​​​​​​​​​​​ – brasofilo Sep 10 '13 at 23:29

Mouse over the left of the tower of hello

Yay you can follow instructions hello

Apparently <kbd> is immune to spoilers

hi

hi again

hi yet again

potato

why is this text drifting out

help

! spoilers don't work now?

! hey that's messed up

now they do?!?!

• Apparently two or more spoiler blocks in a row stop being interpreted as spoiler blocks. Divide them with something else (e.g. with a <!---->) and they'll work (independently though, and they'll be visible as separate blocks too). – Andriy M Jul 11 '13 at 8:36

I've always wondered how to put a backtick in a backtick, now I know. Use 2 backticks as delimiters.  .

SELECT a from table where b=c;

• Documented here, Rocket. – Arjan Feb 4 '13 at 17:52
• @Arjan: Thanks for that link :-) – Rocket Hazmat Feb 4 '13 at 18:06
• test this is a test int x – Thomas Feb 16 '13 at 4:52
starts with codez


w00t woot

<pre><code> has highlighting too:

Look ma, <em style="xyz">highlighting<em>!


Testing magical links to questions RegEx match open tags except XHTML self-contained tags and answers https://stackoverflow.com/a/1732454/851811 using the Share button.

• /[[^]]*]/g ... – nhahtdh Mar 19 '13 at 20:30
• Test leading space ​ lead, test trailing space trail . Space ​ . – nhahtdh Apr 5 '13 at 16:11
• Two ​ jjj sdfsdfsdfsf – nhahtdh Apr 5 '13 at 16:21
• ---strike--- --test-- ~~another~~ ~~~test~~~ – nhahtdh Aug 13 '15 at 6:27

what is this magic dust that causes things to appear

Some code formatting for testing of the problem outlined here: What is Wrong with Code Formatting.

asyncTask.ContinueWith(task =>
{
{
// Handle any exceptions to prevent UnobservedTaskException.
{
// Do stuff...
}
break;
else
mainForm.progressRightLabelText = "Operation failed!";
default:
break;
}
}


This does not format correctly.

Just testing:

Code formatting doesn't work well with NO-BREAK SPACE

-38 y1  +  35 y2  +  31 y3  = -3047


11 y1 + -13 y2 + -34 y3 = 784

34 y1 + -21 y2 + 19 y3 = 2949

But works with space (ASCII 32)

-38 y1  +  35 y2  +  31 y3  = -3047

11 y1  + -13 y2  + -34 y3  = 784

34 y1  + -21 y2  +  19 y3  = 2949


>! hides all.

I'd like to see if this causes a formatting problem as described here (this answer is thus a word for word copy of this answer):

I generally get a bad feeling about code that has one view model directly communicating with another. I like the idea that the VVM part of the pattern should be basically pluggable and nothing inside that area of the code should depend of the existence of anything else within that section. The reasoning behind this is that without centralising the logic it can become difficult to define responsibility.

On the other hand, based on your actual code, it may just be that the ApplicationViewModel is badly named, it doesn't make a model accessible to a view, so this may simply be a poor choice of name.

Either way, the solution comes down to a break down of responsibility. The way I see it you have three things to achieve 1) Allow the user to request to connect to an address, 2) Use that address to connect to a server 3) Persist that address. I'd suggest that you need three classes instead of your two.

public class ServiceProvider
{
{
//connect to the server
}
}

public class SettingsProvider
{
{
}

{
}
}

public class ConnectionViewModel
{
private ServiceProvider serviceProvider;

public ConnectionViewModel(ServiceProvider provider)
{
this.serviceProvider = serviceProvider;
}

public void ExecuteConnectCommand()
{
}
}


The next thing to decide is how the address gets to the SettingsProvider. You could pass it in from the ConnectionViewModel as you do currently, but I'm not keen on that because it increases the coupling of the view model and it isn't the responsibility of the ViewModel to know that it needs persisting. Another option is to make the call from the ServiceProvider, but it doesn't really feel to me like it should be the ServiceProvider's responsibility either. In fact it doesn't feel like anyone's responsibility other than the SettingsProvider. Which leads me to believe that the setting provider should listen out for changes to the connected address and persist them without intervention. In other words an event:

public class ServiceProvider
{
public event EventHandler<ConnectedEventArgs> Connected;
{
//connect to the server
if (Connected != null)
{
}
}
}

public class SettingsProvider
{

public SettingsProvider(ServiceProvider serviceProvider)
{
serviceProvider.Connected += serviceProvider_Connected;
}

protected virtual void serviceProvider_Connected(object sender, ConnectedEventArgs e)
{
}

{
}

{
}
}


This introduces tight coupling between the ServiceProvider and the SettingsProvider, which you want to avoid if possible and I'd use an EventAggregator here, which I've discussed in an answer to this question

To address the issues of testability, you now have a very defined expectancy for what each method will do. The ConnectionViewModel will call connect, The ServicePRovider will connect and the SerttingsProvider will persist. To test the ConnectionViewModel you probably want to convert the coupling to the ServiceProvider from a class to an interface:

public class ServiceProvider : IServiceProvider
{
...
}

public class ConnectionViewModel
{
private IServiceProvider serviceProvider;

public ConnectionViewModel(IServiceProvider provider)
{
this.serviceProvider = serviceProvider;
}

...
}


Then you can use a mocking framework to introduce a mocked IServiceProvider that you can check to ensure that the connect method was called with the expected parameters.

Testing the other two classes is more challenging since they will rely on having a real server and real persistent storage device. You can add more layers of indirection to delay this (for example a PersistenceProvider that the SettingsProvider uses) but eventually you leave the world of unit testing and enter integration testing. Generally when I code with the patterns above the models and view models can get good unit test coverage, but the providers require more complicated testing methodologies.

Of course, once you are using a EventAggregator to break coupling and IOC to facilitate testing it is probably worth looking into one of the dependency injection frameworks such as Microsoft's Prism, but even if you are too late along in development to re-architect a lot of the rules and patterns can be applied to existing code in a simpler way.

Here is a link to a random .docx (now fixed)

Here is another and the linkifier is broke

test answer with at least 30 characters

see, look, 30 characters

blah blah more chars

• I like test ing – Rocket Hazmat May 9 '13 at 19:52

n0 quallitee fltr!

tstng coments

• ​‌‍           ​  ​‌‍           ​  ​‌‍           ​ – Doorknob Apr 30 '13 at 1:12
• abc ​‌‍           ​  ​‌‍           ​ – Doorknob Apr 30 '13 at 1:13
• abc ​‌‍           ​ ​‌‍           ​ – Doorknob Apr 30 '13 at 1:13
• abc ​‌‍           ​‌‍          abab – Doorknob Apr 30 '13 at 1:16
• abc ​‌‍          ​‌‍         abab – Doorknob Apr 30 '13 at 1:16
• abc ​‌‍         ​‌‍        abab – Doorknob Apr 30 '13 at 1:17
• abc ​‌‍          ​‌‍         abab – Doorknob Apr 30 '13 at 1:18
• abc ​‌‍        ​‌‍       abab – Doorknob Apr 30 '13 at 1:18
• abc ​‌‍       ​‌‍      abab – Doorknob Apr 30 '13 at 1:19
• abc ​‌‍       ​‌‍      abab – Doorknob Apr 30 '13 at 1:19
• abc ​‌‍      ​‌‍     abab – Doorknob Apr 30 '13 at 1:19
• abc ​‌‍     ​‌‍    abab – Doorknob Apr 30 '13 at 1:20
• abc ​‌‍    ​‌‍   abab – Doorknob Apr 30 '13 at 1:20
• abc ​‌‍   ​‌‍  abab – Doorknob Apr 30 '13 at 1:20
• abc ​‌‍ ​‌‍ abab – Doorknob Apr 30 '13 at 1:21

Hoy ! This is a test !

La femme est un sujet sur lequel l'homme aime à s'étendre.

• If you test for quality filter, there's none on Meta. :) – Shadow Wizard Wearing Mask May 23 '13 at 17:47
• La souris est en dessous de la table. Le chat est sur la chaise. Le singe est sur la branche. – MikeTheLiar May 23 '13 at 18:41

>

• This one completely breaks the page on an iPad – brasofilo Sep 27 '13 at 13:00
• @Kyle You missed the whole purpose of this test. I was testing to see if I could leave an entirely blank answer. – Piccolo May 2 '13 at 7:33
• Your test was a success. I was running a different test. Sorry. – Kyle Strand May 2 '13 at 7:34
• @KyleStrand Oh, I see. Never mind then. – Piccolo May 2 '13 at 7:36
1. line of code
another one

2. line of code in a different block


Nope, they don't go seamlessly.

• ---strike--- through? – Andriy M Jun 4 '13 at 21:29
• Multi line comment? – Andriy M Feb 25 '14 at 18:30
• Mid-word formatting. – Andriy M Jan 13 '16 at 13:10
• $$\sqrt{(a_1-b_1)^2+(a_2-b_2)^2+...+(a_n-b_n)^2}$$ ? Nope. – Andriy M Dec 20 '16 at 13:58
• [help/merging-accounts]? Nope. – Andriy M Feb 7 '17 at 15:29

#test { background:#f00; }