You are here
Technology
Ready for testing: First-ever supercomputer powered by Intel's wildcard AI chips
The University of San Diego Supercomputer Center (SDSC) says it's ready to run test workloads on its experimental Voyager AI system, which looks to be the first-ever Intel Habana-based supercomputer.…
Landmark case recognizes Bored Ape NFT as an asset
For the first time, a court has issued an injunction to stop the sale and transfer of a non-fungible token (NFT) at the request of a previous owner.…
Engineers Investigating NASA's Voyager 1 Telemetry Data
Read more of this story at Slashdot.
Hot glare of the spotlight doesn’t slow BlackByte ransomware gang
The US government's alert three months ago warning businesses and government agencies about the threat of BlackByte has apparently done little to slow down the ransomware group's activities.…
BT: 'Quantum radios' could boost 5G network range
Brit telecoms giant BT is undertaking a trial of new antenna technology that may boost the range of 5G networks and reduce mobile network energy consumption.…
Logitech Pop: Stylish, portable, but far from the best typing experience
So many mechanical keyboards put function ahead of form. Put less charitably, they're ugly as sin. The Logitech Pop, a $100 wireless mechanical keyboard, tries to play both sides of the field.…
Google's first report on Privacy Sandbox hits UK watchdog's inbox
As Google's self-imposed "late 2023" deadline to kill all third party cookies in its Chrome browser looms, the giant has handed in its first quarterly Privacy Sandbox report to the UK's competition regulator.…
Despite ban, China surges back to second place on bitcoin mining charts
China has become the world’s second most prolific miner of bitcoin – or maybe it always was – according to new data from the Cambridge Centre for Alternative Finance (CCAF).…
Rocket Engine Exhaust Pollution Extends High Into Earth's Atmosphere
Read more of this story at Slashdot.
Microsoft-backed robovans to deliver grub in London
Microsoft is pumping supercomputing oomph as well as funds into a British-born autonomous vehicle startup.…
Voyager 1 space probe producing ‘anomalous telemetry data’
NASA engineers are investigating anomalous telemetry data produced by venerable space probe Voyager 1.…
CodeSOD: The String Buildulator
"Don't concatenate long strings," is generally solid advice in most languages. Due to internal representations, strings are frequently immutable and of a fixed length, so a block like this:
string s = getSomeString(); s = s + "some suffix";creates three strings- the original, the suffix, and the third, concatenated string. Keep spamming instances, especially long ones, if you want to stress test your garbage collector.
While languages will do their best to optimize those kinds of operations, the general advice is to use string builders which can minimize those allocations and boost performance.
Or, you can do what Richard B's predecessor did, and abuse the heck out of string interpolation in C#.
.comment { border: none; } StreamWriter sw = new StreamWriter(filename); #region Export file header string header = ""; header = "Title"; header = $"{header},\"First Name\""; header = $"{header},\"Middle Name\""; header = $"{header},\"Last Name\""; header = $"{header},Suffix"; header = $"{header},Company"; header = $"{header},Department"; header = $"{header},\"Job Title\""; header = $"{header},\"Business Street\""; header = $"{header},\"Business Street 2\""; header = $"{header},\"Business Street 3\""; header = $"{header},\"Business City\""; header = $"{header},\"Business State\""; header = $"{header},\"Business Postal Code\""; header = $"{header},\"Business Country/ Region\""; header = $"{header},\"Home Street\""; header = $"{header},\"Home Street 2\""; header = $"{header},\"Home Street 3\""; header = $"{header},\"Home City\""; header = $"{header},\"Home State\""; header = $"{header},\"Home Postal Code\""; header = $"{header},\"Home Country/ Region\""; header = $"{header},\"Other Street\""; header = $"{header},\"Other Street 2\""; header = $"{header},\"Other Street 3\""; header = $"{header},\"Other City\""; header = $"{header},\"Other State\""; header = $"{header},\"Other Postal Code\""; header = $"{header},\"Other Country/ Region\""; header = $"{header},\"Assistant's Phone\""; header = $"{header},\"Business Fax\""; header = $"{header},\"Business Phone\""; header = $"{header},\"Business Phone 2\""; header = $"{header},Callback"; header = $"{header},\"Car Phone\""; header = $"{header},\"Company Main Phone\""; header = $"{header},\"Home Fax\""; header = $"{header},\"Home Phone\""; header = $"{header},\"Home Phone 2\""; header = $"{header},ISDN"; header = $"{header},\"Mobile Phone\""; header = $"{header},\"Other Fax\""; header = $"{header},\"Other Phone\""; header = $"{header},Pager"; header = $"{header},\"Primary Phone\""; header = $"{header},\"Radio Phone\""; header = $"{header},\"TTY/TDD Phone\""; header = $"{header},Telex"; header = $"{header},Account"; header = $"{header},Anniversary"; header = $"{header},\"Assistant's Name\""; header = $"{header},\"Billing Information\""; header = $"{header},Birthday"; header = $"{header},\"Business Address PO Box\""; header = $"{header},Categories"; header = $"{header},Children"; header = $"{header},\"Directory Server\""; header = $"{header},\"E - mail Address\""; header = $"{header},\"E - mail Type\""; header = $"{header},\"E - mail Display Name\""; header = $"{header},\"E-mail 2 Address\""; header = $"{header},\"E - mail 2 Type\""; header = $"{header},\"E - mail 2 Display Name\""; header = $"{header},\"E-mail 3 Address\""; header = $"{header},\"E - mail 3 Type\""; header = $"{header},\"E - mail 3 Display Name\""; header = $"{header},Gender"; header = $"{header},\"Government ID Number\""; header = $"{header},Hobby"; header = $"{header},\"Home Address PO Box\""; header = $"{header},Initials"; header = $"{header},\"Internet Free Busy\""; header = $"{header},Keywords"; header = $"{header},Language"; header = $"{header},Location"; header = $"{header},\"Manager's Name\""; header = $"{header},Mileage"; header = $"{header},Notes"; header = $"{header},\"Office Location\""; header = $"{header},\"Organizational ID Number\""; header = $"{header},\"Other Address PO Box\""; header = $"{header},Priority"; header = $"{header},Private"; header = $"{header},Profession"; header = $"{header},\"Referred By\""; header = $"{header},Sensitivity"; header = $"{header},Spouse"; header = $"{header},\"User 1\""; header = $"{header},\"User 2\""; header = $"{header},\"User 3\""; header = $"{header},\"User 4\""; header = $"{header},\"Web Page\""; #endregion Export file header sw.WriteLine(header);The real killer to this is that there's no need for string concatenation at all. There's no reason one needs to WriteLine the entire header at once. sw.Write("Title,"); Also, string interpolation is almost always more expensive than straight concatenation, and harder for compilers to optimize. I'm not about to benchmark this disaster to prove it, but I suspect this is going to be pretty much the most expensive option.
And don't worry, the same basic process follows for each individual row they're outputting:
string contactRow = ""; HtmlToText htmlToText = new HtmlToText(); bool extendedPropRetrieved = false; #region Extract properties for export file if (contact.CompleteName != null) contactRow = $"\"{contact.CompleteName.Title}\""; // Title else contactRow = $""; contactRow = $"{contactRow},\"{contact.GivenName}\""; // First name contactRow = $"{contactRow},\"{contact.MiddleName}\""; // Middle name contactRow = $"{contactRow},\"{contact.Surname}\""; // Last name if (contact.CompleteName != null) contactRow = $"{contactRow},\"{contact.CompleteName.Suffix}\""; //Suffix else contactRow = $"{contactRow},"; contactRow = $"{contactRow},\"{contact.CompanyName}\""; // Company contactRow = $"{contactRow},\"{contact.Department}\""; // Department contactRow = $"{contactRow},\"{contact.JobTitle}\""; // Job title if (contact.PhysicalAddresses.Contains(PhysicalAddressKey.Business)) { contactRow = $"{contactRow},\"{contact.PhysicalAddresses[PhysicalAddressKey.Business].Street}\""; // Business street contactRow = $"{contactRow},"; // Business street 2 contactRow = $"{contactRow},"; // Business street 3 contactRow = $"{contactRow},\"{contact.PhysicalAddresses[PhysicalAddressKey.Business].City}\""; // Business city contactRow = $"{contactRow},\"{contact.PhysicalAddresses[PhysicalAddressKey.Business].State}\""; // Business state contactRow = $"{contactRow},\"{contact.PhysicalAddresses[PhysicalAddressKey.Business].PostalCode}\""; // Business postalcode contactRow = $"{contactRow},\"{contact.PhysicalAddresses[PhysicalAddressKey.Business].CountryOrRegion}\""; // Business country/region } else { contactRow = $"{contactRow},"; contactRow = $"{contactRow},"; contactRow = $"{contactRow},"; contactRow = $"{contactRow},"; contactRow = $"{contactRow},"; contactRow = $"{contactRow},"; contactRow = $"{contactRow},"; } // ... this goes on for about 600 linesThe physical address else block is something really special, here.
hljs.initHighlightingOnLoad();
Your snoozing iOS 15 iPhone may actually be sleeping with one antenna open
Some research into the potentially exploitable low-power state of iPhones has sparked headlines this week.…
China will produce one in five of the chips it uses in 2026, says analyst
China’s integrated circuit (IC) production has failed to keep pace with its appetite for silicon, with market research firm IC Insights predcicting the nation will produce only one in five ICs it uses in 2026.…
New Bluetooth Hack Can Unlock All Kinds of Devices
Read more of this story at Slashdot.
Tencent happily parting ways with loss-making cloud customers
Chinese tech giant Tencent has recorded its first ever quarter-to-quarter revenue fall, warned that COVID-19 lockdowns will hurt messing with its business, and cautioned against assumptions that Beijing is ready to enthusiastically support tech companies.…
Solar-Powered Desalination Device Wins MIT $100K Competition
Read more of this story at Slashdot.
Google Russia goes broke after bank account snatched
Google Russia is shutting down and filing for bankruptcy after Vladimir Putin's government confiscated the Chocolate Factory's bank account in the nation.…
Older People Using TikTok To Defy Ageist Stereotypes, Research Finds
Read more of this story at Slashdot.
Netflix Customers Canceling Service Increasingly Includes Long-Term Subscribers
Read more of this story at Slashdot.
Pages
