Compare commits
	
		
			2 commits
		
	
	
		
			ad8b48fbc3
			...
			7411c96c06
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							 | 
						7411c96c06 | ||
| 
							 | 
						deb067b2b7 | 
					 3 changed files with 66 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -183,7 +183,7 @@ The first thing I noticed was that I got some new warnings when compiling, all o
 | 
			
		|||
Next up, I added cargo-bloat to my flake. This tool can show you which functions take up most of the space in your binary.
 | 
			
		||||
The invocation is similar to building - `cargo bloat --example announce --profile=size-optimized` resulted in the following output:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
```text
 | 
			
		||||
File  .text     Size        Crate Name
 | 
			
		||||
 1.0%   5.5%  21.0KiB clap_builder clap_builder::parser::parser::Parser::get_matches_with
 | 
			
		||||
 0.9%   5.3%  20.5KiB          std std::backtrace_rs::symbolize::gimli::Cache::with_global
 | 
			
		||||
| 
						 | 
				
			
			@ -224,9 +224,9 @@ Let's cover those points in order.
 | 
			
		|||
 | 
			
		||||
Using `GNU size`, we can check the size per section in the ELF binary.
 | 
			
		||||
Using `-G` or `-B` output formats does not work for this, as it will only show the `.text` and `.data` section, which in this case only make up around 500KB.
 | 
			
		||||
Thus the command I used was ` size -A --common target/size-optimized/examples/announce`, giving the following result:
 | 
			
		||||
Thus the command I used was `size -A --common target/size-optimized/examples/announce`, giving the following result:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
```text
 | 
			
		||||
section                size     addr
 | 
			
		||||
.dynsym                1680      856
 | 
			
		||||
.dynstr                1198     3500
 | 
			
		||||
| 
						 | 
				
			
			@ -260,7 +260,8 @@ While clap is super handy, it looks like the code needed to parse two simple arg
 | 
			
		|||
As the C program I was comparing against had all the parameters hard-coded, I just ripped out the dependency and hard-coded the values I needed.
 | 
			
		||||
 | 
			
		||||
The result is the first version of `tiny_announce`, as I did not want to change the existing example.
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```rust
 | 
			
		||||
//! An example for how to send text to the display.
 | 
			
		||||
 | 
			
		||||
use servicepoint::{
 | 
			
		||||
| 
						 | 
				
			
			@ -308,7 +309,7 @@ This produces a binary that is now only 30.992 bytes!
 | 
			
		|||
 | 
			
		||||
The remaining top 3 functions were:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
```text
 | 
			
		||||
 File  .text    Size         Crate Name
 | 
			
		||||
 4.4%  11.0%  2.0KiB           std <&T as std::net::socket_addr::ToSocketAddrs>::to_socket_addrs
 | 
			
		||||
 3.8%   9.4%  1.7KiB tiny_announce tiny_announce::main
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -102,7 +102,7 @@ This is useful, for example, if the target environment you're developing for can
 | 
			
		|||
 | 
			
		||||
For me, the trade-offs are worth it, as they provide greater transparency and control over the flake configuration.
 | 
			
		||||
 | 
			
		||||
That being said, I fully acknowledge that `flake-utils` can still be a great choice for many people. 
 | 
			
		||||
That being said, I fully acknowledge that `flake-utils` can still be a great choice for many people.
 | 
			
		||||
It simplifies things and reduces the need to write boilerplate code, which can be a plus depending on your needs and workflow.
 | 
			
		||||
Ultimately, it's also matter of personal preference.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										59
									
								
								layouts/_default/rss.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								layouts/_default/rss.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,59 @@
 | 
			
		|||
{{- $authorEmail := "" }}
 | 
			
		||||
{{- with site.Params.author }}
 | 
			
		||||
  {{- if reflect.IsMap . }}
 | 
			
		||||
    {{- with .email }}
 | 
			
		||||
      {{- $authorEmail = . }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
  {{- end }}
 | 
			
		||||
{{- end }}
 | 
			
		||||
 | 
			
		||||
{{- $authorName := "" }}
 | 
			
		||||
{{- with site.Params.author }}
 | 
			
		||||
  {{- if reflect.IsMap . }}
 | 
			
		||||
    {{- with .name }}
 | 
			
		||||
      {{- $authorName = . }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
  {{- else }}
 | 
			
		||||
    {{- $authorName  = . }}
 | 
			
		||||
  {{- end }}
 | 
			
		||||
{{- end }}
 | 
			
		||||
 | 
			
		||||
{{- $pctx := . }}
 | 
			
		||||
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
 | 
			
		||||
{{- $pages := slice }}
 | 
			
		||||
{{- if or $.IsHome $.IsSection }}
 | 
			
		||||
{{- $pages = $pctx.RegularPages }}
 | 
			
		||||
{{- else }}
 | 
			
		||||
{{- $pages = $pctx.Pages }}
 | 
			
		||||
{{- end }}
 | 
			
		||||
{{- $limit := .Site.Config.Services.RSS.Limit }}
 | 
			
		||||
{{- if ge $limit 1 }}
 | 
			
		||||
{{- $pages = $pages | first $limit }}
 | 
			
		||||
{{- end }}
 | 
			
		||||
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
 | 
			
		||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
 | 
			
		||||
  <channel>
 | 
			
		||||
    <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }}</title>
 | 
			
		||||
    <link>{{ .Permalink }}</link>
 | 
			
		||||
    <description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description>
 | 
			
		||||
    <generator>Hugo</generator>
 | 
			
		||||
    <language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
 | 
			
		||||
    <managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
 | 
			
		||||
    <webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
 | 
			
		||||
    <copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
 | 
			
		||||
    <lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
 | 
			
		||||
    {{- with .OutputFormats.Get "RSS" }}
 | 
			
		||||
    {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
    {{- range $pages }}
 | 
			
		||||
    <item>
 | 
			
		||||
      <title>{{ .Title }}</title>
 | 
			
		||||
      <link>{{ .Permalink }}</link>
 | 
			
		||||
      <pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
 | 
			
		||||
      {{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
 | 
			
		||||
      <guid>{{ .Permalink }}</guid>
 | 
			
		||||
      <description>{{ .Content | transform.XMLEscape | safeHTML }}</description>
 | 
			
		||||
    </item>
 | 
			
		||||
    {{- end }}
 | 
			
		||||
  </channel>
 | 
			
		||||
</rss>
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue