|
Of course, but the built-in methods of System.Char (.net) don't suit my needs, so I rolled my own as is my wont.
I actually have a number of places where I have to roll my own character (or byte) classing solution to meet my requirements.
The "delimiter" class in particular depends on the type of file being read -- for JSON, the delimiters are { } [ ] : , ; for CSV they are , \r \n .
|
|
|
|
|
I was talking about the method, not the functions themselves. The basic idea is that you can assign up to 8 distinct classes to each character. Fleshing out a bit more my idea, something like:
tab['{'] = CLASS_DELIM_JSON;
tab[','] = CLASS_DELIM_JSON | CLASS_DELIM_CSV; The table would of course be statically allocated and initialized:
bool is_a (int x, char what)
{
static char tab[128] = { };
return (tab[(char)x] & what) != 0;
}
Mircea
|
|
|
|
|
Yes, and that's what I'm doing here -- but C#ishly, using an enum to define the constants and the map.
|
|
|
|
|
PIEBALDconsult wrote: BUT once in a while we receive a corrupt file...but firing a million times in rapid succession is decidedly not
Why does it continue after the first one? If firing once means it is corrupt and then you expect the rest to be corrupt then why not stop?
Or say stop after 10 or so?
PIEBALDconsult wrote: to add a test for i > 127 and avoid the exception (which I am loathe to do on principle).
Not sure I understand that statement. Unicode does not fit that range and you are getting unicode. So testing for it rather than assuming it is correct is what should be happening.
|
|
|
|
|
The reader has no clue whether what it's reading is corrupt or not, that's determined at a higher level. The reader's job is to simply read the characters and return them.
jschell wrote: Or say stop after 10 or so?
That's the issue I was running into, I had it throw an Exception after ten seconds, I needed to keep that from happening.
jschell wrote: you are getting unicode
Yes, but the reader was taking too long to read the UNICODE characters which are outside the ASCII range. It now reads them almost as quickly as UNICODE characters which are within the ASCII range.
But to do so, It's flipping between two implementations of a method -- one for ASCII and another for non-ASCII -- depending on which characters it encounters.
|
|
|
|
|
I think Chris will have to update the Lounge rules - no posts about what ChatGTP says!
Me: Write me a poem about programming
Chat GPT:
Programming, so complex and so hard
It can make your head spin, like a spinning top
It can be difficult to understand
But once you do, it can never be topped
From the basics of HTML to the depths of Java
Programming is a skill that's hard to master
But with enough dedication and hard work
You can be a coding master
The possibilities are endless with programming
You can create something that's truly unique
From a simple website to a complex game
You can make something that's truly one-of-a-kind
It can be frustrating and time-consuming
But the rewards can be great
You can make something that others can use
And that's a feeling that can't be beat
So don't give up when it gets tough
And don't let the obstacles stand in your way
With enough dedication and hard work
You too can be a coding master one day!
|
|
|
|
|
It bothers me that this would work as a reasonably structured song if you made a chorus about being a coding master.
Thanks,
Sean Ewington
CodeProject
|
|
|
|
|
Sean Ewington wrote: this would work as a reasonably structured song if you made a chorus about being a coding master.
Reminds me of the song: Juke Box Hero - YouTube[^]
|
|
|
|
|
One of my ultimate bands and songs!
|
|
|
|
|
 Not anywhere near as good as this :
DR. SEUSS EXPLAINS COMPUTERS
(Original author unknown) Extracted from A Grandchild's Guide to Using Grandpa's Computer by Gene Zeigler
If a packet hits a pocket on a socket on a port,
And the bus is interrupted as a very last resort,
And the address of the memory makes your floppy disc abort,
Then the socket packet pocket has an error to report.
If your cursor finds a menu item followed by a dash,
And the double-clicking icon puts your window in the trash,
And your data is corrupted 'cause the index does not flash,
Then your situation’s hopeless and your system’s gonna crash!
If the label on the cable on the table at your house,
Says the network is connected to the button on your mouse,
But your packets want to tunnel on another protocol,
That’s repeatedly rejected by the printer down the hall,
And your screen is all distorted by the side effects of gauss,
So your icons in the window are as wavy as a souse,
Then you may as well reboot and go out with a bang,
'cause as sure as I’m a poet, the suckers gonna hang.
When the copy of your floppy’s getting sloppy on the disc,
And the micro code instructions cause unnecessary risk,
Then you have to flash your memory, and you’ll want to RAM your ROM…
Quickly turn off your computer and go and tell your Mom.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
We are no longer allowed to appreciate Dr. Seuss in America as he has been deemed a racist. Just by reading this post I could technically, literally, and figuratively be canceled.
|
|
|
|
|
That is entirely USians' loss.
I followed the controversy as it developed in the US. All I can say is that if an author can be deemed racist for a couple of elements in one drawing out of N illustrated books, then something is very wrong in the US. I remember reading the controversial book (And to think I saw it on Mulberry Street, IIRC) as a child, and all I thought about the drawings of "foreigners" was that they certainly dress funnily in "foreign parts".
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
I'm a redneck American through and through. My blood bleeds red, white, and blue. That means I can talk about it.
100% agree with you there on it being our loss. The US is in a state of decline and, unless something drastic changes, our course is headed towards being nothing more than a story of what used to be. Which is very, very sad to see happen. But it's also the reality of the situation.
Can't really say much else without getting in the weeds... but the US is hurting as we watch it be intentionally destroyed from the inside out.
Jeremy Falcon
|
|
|
|
|
Nice lyrics indeed ... I was not that lucky to talk to ChatGPT, as he usually greets me with "I am busy, come back later ..."
|
|
|
|
|
Sucks, Keep your day job.
|
|
|
|
|
Roses are #ff0000,
Violets are blue,
zeros and ones,
but never a two
|
|
|
|
|
Taking a leaf from JavaScript's clarity of definition for equality, in Span<T>.Inequality(Span<T>, Span<T>) Operator (System) | Microsoft Learn , the following definition of equality seems a bit suspect...
"Two Span<t> objects are equal if they have different lengths or if the corresponding elements of left and right do not point to the same memory."
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Someone forgot to add "not" when they copied the remarks from the equality operator.
Two Span<T> objects are equal if they have the same length and the corresponding elements of left and right point to the same memory.
IIRC, there used to be a way to report such problems directly from the page, but it looks like they've abandoned that idea.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Managed to find the option to edit the page by creating a pull request on GitHub[^]. The documentation should be correctly shortly.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I opened up my laptop and noticed that it was responding super slowly.
It's AMD R7 8-core (4 core with threading-tech) with 16GB RAM running Win10 and it always performs very well.
Internet?? or was it the laptop itself??
8 Cores All At Same Level of Utilization? Unlikely!
I checked the CPU Utilization and saw this (snapshot)[^].
Isn't that interesting?? I've never seen all 8 cores report that they are exactly utilized the same.
I closed CPU monitor and opened it again and saw the same thing.
After Reboot: Looks Normal Again
Here's a snapshot that seems more realistic[^].
Then I Noticed...
Hey, check out the first graphic and you'll see that the Speed was at .38GHz -- even though these chips are really at 2.0GHz
Not sure what happened there, so we are filing it under Weird!! 
modified 25-Jan-23 14:37pm.
|
|
|
|
|
Fake processor!

|
|
|
|
|
That flat 19% utilization of all cores is rather strange.
All modern general chips are prepared to reduce the clock speed when load is low, to reduce heating and battery drain. I have seen my 3.3 GHz CPU going down to about 1000 MHz, never as low as 380 MHz. Maybe I am good at keeping it busy . Maybe the OS routine that should increase your clock speed when needed crashed, and 380 MHz is some sort of minimum value (for your processor), so it never was raised, and that is why your PC was sluggish.
Your CPU was stuck at approx. 1/5 its max clock speed. The CPU utilization was approx. 1/5 of the total capacity. If 19% utilization refers to the capacity at full clock speed rather than the current one (I don't know which is the case!), then the flat 19% can be read as '100% utilization at the current clock speed'. If there is a great backlog of CPU tasks, it isn't surprising that all cores are saturated. When I run Handbrake, I see all cores at flat 100% utilization for minutes at a time (at the nominal 3.3 MHz clock frequency). Trying to use the PC for other tasks in parallel with Handbrake is futile.
If you immediately after boot up turn on the Resource Monitor CPU view, you will loads of processes coming and going, for completing the boot up. When you see the login screen, there is still a lot to be done in the background. It takes several minutes before activity calms down, even if you do not touch the keyboard, activate no user task. If the CPU is strangled to 1/5 the normal speed, it may take five times as long. Maybe this startup activity is what you saw saturating all cores (given the clock speed reduction).
If this theory is correct, the one remaining problem is: What caused your PC to refuse to raise the clock frequency? If it had done so, that backlog of startup tasks could have been processed before you even noticed it. I have no idea about what could cause the clock adjustment to fail. (I have never looked into Windows source code at all - never had access to it, never cared to.)
|
|
|
|
|
I noticed from your first screenshot, your last boot-up was three days ago, so those 19% load isn't startup tasks!
However, the PC spends almost 8 GiBytes of RAM on something. 18% disk activity on a fast SSD, is remarkable. For a good WiFi unit, 104 Kbps isn't that much, but some process is using it. I am not familiar with AMD GPUs, but if your are just displaying the Task Manager, 27% utilization is somewhat on the high side. There is something keeping your CPU busy (and RAM, and disk, and GPU), even if it isn't startup tasks!
Compare that to the second screen dump: Half the memory load, 1% disk, half the Wi-Fi load, less than half GPU load (still surprising high, though!), half the handle count thread count. 1:34 after boot up, some of the load could come from start up tasks.
Before rebooting your PC, you could have produced screen dumps of process lists and thread counts and I/O-activity, to see which might be suspected for preventing the clock speed adjustment (it could still be a long way to the answer, though). If you experience the same again, you may want to take dumps of all the Resource Monitor's displays.
In the DOS days, any software problem could be handled by Ctrl-Alt-Delete. This is the first time for many years that I hear of that 
|
|
|
|
|
Fantastic info! Thanks for replying.
trønderen wrote: then the flat 19% can be read as '100% utilization at the current clock speed'. If there is a great backlog of CPU tasks, it isn't surprising that all cores are saturated.
Yes, that was exactly what I was thinking too.
trønderen wrote: immediately after boot up turn on the Resource Monitor CPU view, you will loads of processes coming and going
I've definitely noticed this.
In my case my laptop had been sitting idle overnight (plugged in). I removed the plug then opened the lid. I think this is what caused the problem. It was probably in low-power mode then I removed the plug and I know from past that this laptop (and Microsoft) try to idle some cores to save power.
I think it attempted to do that but then I was attempting to activate the laptop also and something went screwy.
Also, notice that when my laptop is removed from power, it tries to idle the last 4 cores (to conserve power) even though I've forced my laptop to have the setting "prefer speed over power saving".
I've talked at length with people about this and many say "there is a BIOS setting!" But there actually isn't on my (quite new) HP laptop.
What I've Learned, What I will Try Next Time
In future I will first activate my laptop (open the lid) then after I see the desktop and only after will I pull the plug. Should'a been doing this all along but the hardware & software shouldn't do that anyways.
Thanks again for the discussion, really great info.
|
|
|
|
|
Hmm, if this happens a lot I would check the CPU temperature. Probably just a bug though.
|
|
|
|
|